Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package com.qbiel.koneksi;
  2.  
  3.  
  4. import com.mysql.jdbc.Connection;
  5. import com.mysql.jdbc.Driver;
  6. import java.sql.DriverManager;
  7. import java.sql.SQLException;
  8.  
  9. /**
  10. *
  11. * @author qbiel
  12. */
  13. public class Koneksi {
  14.  
  15. private static Connection konek;
  16.  
  17.  
  18. public static Connection getConnection() throws SQLException{
  19. String url = "jdbc:mysql://localhost/Jurusan";
  20. String user = "root";
  21. String pass = "root";
  22. if (konek == null){
  23. try{
  24.  
  25.  
  26. Driver driver = new Driver();
  27. konek = (Connection) DriverManager.getConnection(url,user,pass);
  28.  
  29. }catch(Exception e){
  30. System.err.println("Error "+e);
  31. }
  32.  
  33. }
  34.  
  35.  
  36. return konek;
  37. }
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement