Advertisement
BlasToIce

Script_P7_Koneksi

Dec 24th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement