Koneksi Database dengan Java

public void koneksiDatabase() {
try {
Class.forName(“com.mysql.jdbc.Driver”);
System.out.println(“Sukses Driver JDBC ditemukan ….”);
try {
String url = “jdbc:mysql://localhost:3306/Database05?user=fatwati&password=ternate”;

konek = DriverManager.getConnection(url);

System.out.println(“Sukses Koneksi ….”);

String url = “jdbc:odbc:DNSGL”;

String user = “”;

String pass = “”;

konek = DriverManager.getConnection(url, user, pass);

System.out.println(“Sukses Koneksi ….”) ; }

catch (SQLException se) {

System.out.println(“Koneksi Gagal = ” + se);

System.exit(0); }
}

catch (ClassNotFoundException cnfe) {

System.out.println(“Class tidak ditemukan.. Error : ” + cnfe);

System.exit(0);

}

}

Pos Sebelumnya
Tinggalkan komentar

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: