Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATABASE IN JAVA.

Similar presentations


Presentation on theme: "DATABASE IN JAVA."— Presentation transcript:

1 DATABASE IN JAVA

2 DATABASE BUAT DATABASE TERLEBIH DAHULU DENGAN MYSQL MISAL MELALUI XAMPP/ PHPTRIAD PHPTRIAD: START  PROGRAM  PHPTRIAD  MYSQL  MYSQL D-NT / APACHE CONSOLE  START APACHE XAMPP: START  APACHE FRIENDS  XAMPP  XAMPP CONTROL PANEL  START APACHE DAN MYSQL

3 BUKA BROWSER LALU KETIKKAN : LOCALHOST/PHPMYADMIN

4 LANGKAH PEMBUATAN DATABASE (1)
CREATE DATABASE

5 LANGKAH PEMBUATAN DATABASE (2)
CREATE TABLE

6 LANGKAH PEMBUATAN DATABASE (3)
ISIKAN FIELD YG AKAN DIBUAT ATUR TIPE DATANYA SIMPAN TABEL SETIAP KALI AKAN DITAMPILKAN PERINTAH SQL UNTUK MASING – MASING EKSEKUSI PERINTAH PERHATIKAN TAB – TAB YANG TERDAPAT DI BAGIAN ATAS UNTUK BROWSE DAN OPERASI LAIN

7 KONEKSI JAVA-DATABASE (1)
import java.sql.*; public class KoneksiMysql { private String host="localhost"; private String user="root"; private String password=""; private String db="kuliah"; public KoneksiMysql() { Connection conn; Statement st; ResultSet rs; int no=0; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection( "jdbc:mysql://"+ host +"/"+ db +"?user=" + user + "&password="+ password); st = conn.createStatement(); rs = st.executeQuery("Select * from mahasiswa");

8 KONEKSI JAVA-DATABASE (2)
while (rs.next()) { no=no+1; System.out.println(no + ")"); System.out.println("NIM :" +rs.getString("NIM")); System.out.println("Nama :" +rs.getString("nama")); System.out.println("Umur :" +rs.getString(3)); System.out.println("================================"); } conn.close(); catch(Exception e) { System.out.println("Pesan kesalahan : "+ e.getMessage()); public static void main(String[] args) { KoneksiMysql koneksimysql = new KoneksiMysql();

9 KONEKSI JAVA-DATABASE (3)


Download ppt "DATABASE IN JAVA."

Similar presentations


Ads by Google