Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package siakad.mahasiswa;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7.  
  8. public class koneksiMySQL
  9. {
  10. String driver = "com.mysql.jdbc.Driver";
  11. String url = "jdbc:mysql://localhost:3306/siakad";
  12. String usern = "root";
  13. String passw = "";
  14. Connection con;
  15. PreparedStatement ps;
  16. ResultSet rs;
  17.  
  18. public Connection getCon()
  19. {
  20. try
  21. {
  22. Class.forName(driver);
  23. con = DriverManager.getConnection(url, usern, passw);
  24. }
  25. catch(Exception ex)
  26. {
  27. System.out.println(ex.getMessage());
  28. }
  29. return con;
  30. }
  31. }