import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author USER
*/
public class Koneksi {
private static Connection koneksi;
public static Connection getKoneksi() {
if (koneksi == null) {
try {
String url = "jdbc:mysql://localhost/laundry";
String username = "root";
String password = "";
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
koneksi = DriverManager.getConnection(url, username, password);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "KONEKSI KE SERVER GAGAL !\n PERIKSALAH KEMBALI KONEKSI JARINGAN!");
}
}
return koneksi;
}
}
No comments:
Post a Comment