Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Koneksi {
- public Koneksi(){
- try {
- String driver = "com.mysql.jdbc.Driver";
- Class.forName(driver);
- System.out.println("sukses memanggil driver");
- } catch (Exception e) {
- System.out.println("gagal memanggil driver :"+e.getMessage());
- }
- }
- public Connection KonektoDB(){
- Connection Koneksi = null;
- try {
- String url = "jdbc:mysql://localhost/Nama_database";
- String user = "root";
- String pass = "";
- Koneksi = DriverManager.getConnection(url,user,pass);
- } catch (Exception e) {
- System.out.println("koneksi database gagal :" +e.getMessage());
- }
- return Koneksi;
- }
- }
Add Comment
Please, Sign In to add comment