Advertisement
pendekar_langit

koneksi

Nov 24th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package rentalmobil.user;
  8. import java.sql.*;
  9. import javax.swing.JOptionPane;
  10. /**
  11.  *
  12.  * @author surya
  13.  */
  14. public class koneksi {
  15. private static Connection conn;
  16. public static Connection getconn(){
  17.     if(conn == null){
  18.         try{
  19.             String url = "jdbc:mysql://localhost/rental_mobil";
  20.             String user = "root";
  21.             String password = "";
  22.             DriverManager.registerDriver(new com.mysql.jdbc.Driver());
  23.             DriverManager.getConnection(url,user,password);
  24.             JOptionPane.showMessageDialog(null, "Koneksi berhasil !!!");
  25.         }catch (SQLException t){
  26.             JOptionPane.showMessageDialog(null, "Koneksi gagal !!!");
  27.         }
  28.     }
  29.     return conn;
  30. }
  31.  
  32.  
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement