Guest User

Untitled

a guest
Oct 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package newbieilmu.rawatinap;
  2.  
  3. import javax.swing.*;
  4. import java.sql.*;
  5.  
  6. public class Koneksi
  7. {
  8.  
  9. public Koneksi()
  10. {
  11. }
  12.  
  13. public Connection open_a_Connection() throws SQLException
  14. {
  15. Connection connect= null;
  16. try
  17. {
  18. Class.forName("com.mysql.jdbc.Driver");
  19. connect = DriverManager.getConnection("jdbc:mysql://localhost/db_rawatinap","root","root");
  20. return connect;
  21. }
  22. catch(SQLException ex)
  23. {
  24. JOptionPane.showMessageDialog(null,"Tidak ada koneksi yang terbuka"+ ex,"informasi",JOptionPane.INFORMATION_MESSAGE);
  25. return null;
  26. }
  27.  
  28. catch(Exception e)
  29. {
  30. JOptionPane.showMessageDialog(null,"Tidak dapat membuka koneksi yang terbuka","informasi",JOptionPane.INFORMATION_MESSAGE);
  31. return null;
  32. }
  33. }
  34.  
  35.  
  36. }
Add Comment
Please, Sign In to add comment