Advertisement
Guest User

koneksi

a guest
Mar 18th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package src.id.lib;
  2.  
  3. import com.mysql.jdbc.Driver;
  4. import java.sql.*;
  5.  
  6. public class koneksi {
  7.  
  8.     private static Connection koneksi;
  9.  
  10.     public static Connection GetConnection() throws SQLException {
  11.         if (koneksi == null) {
  12.             new Driver();
  13.             koneksi = DriverManager.getConnection("jdbc:mysql://localhost:3306/workshop_ti_mhsbaru", "root", "");
  14.         }
  15.         return koneksi;
  16.     }
  17.  
  18.     public static void main(String args[]) {
  19.         try {
  20.             GetConnection();
  21.             System.out.println("Koneksi Berhasil");
  22.         } catch (SQLException ex) {
  23.             System.err.println("Koneksi Gagal");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement