Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.koneksi;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Hp
- */
- public class koneksi {
- private static Connection koneksi;
- public static Connection getKoneksi()
- {
- if(koneksi== null)
- {
- try {
- String url="jdbc:mysql://localhost/web";
- String username= "root"; // default username
- String password= ""; // jika ada password bisa anda masukkan
- DriverManager.registerDriver(new com.mysql.jdbc.Driver());
- koneksi =DriverManager.getConnection(url, username, password);
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- return koneksi;
- }
- public void koneksiDatabase() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement