Guest User

Untitled

a guest
Feb 28th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public class Koneksi {
  2. public Koneksi(){
  3. try {
  4. String driver = "com.mysql.jdbc.Driver";
  5. Class.forName(driver);
  6. System.out.println("sukses memanggil driver");
  7. } catch (Exception e) {
  8. System.out.println("gagal memanggil driver :"+e.getMessage());
  9. }
  10. }
  11. public Connection KonektoDB(){
  12. Connection Koneksi = null;
  13. try {
  14. String url = "jdbc:mysql://localhost/Nama_database";
  15. String user = "root";
  16. String pass = "";
  17.  
  18. Koneksi = DriverManager.getConnection(url,user,pass);
  19.  
  20. } catch (Exception e) {
  21. System.out.println("koneksi database gagal :" +e.getMessage());
  22. }
  23. return Koneksi;
  24. }
  25. }
Add Comment
Please, Sign In to add comment