Advertisement
Guest User

Untitled

a guest
Jan 5th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. package Database;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8.  
  9. public class Connect {
  10. public Connection conn = null;
  11. public Statement stmt = null;
  12. public ResultSet rs = null;
  13. private String IP = "Localhost";
  14. private String DB = "abccarrental";
  15. private String UN = "root";
  16. private String PW = "";
  17. private String HT;
  18.  
  19. public Connect() {
  20. this.HT = "jdbc:mysql://" + this.IP + "/" + this.DB;
  21.  
  22. try {
  23. Class.forName("com.mysql.jdbc.Driver").newInstance();
  24. System.out.println("[INFO] : Connecting to " + this.DB + "'s database...");
  25. this.conn = DriverManager.getConnection(this.HT, this.UN, this.PW);
  26. System.out.println(" > IP: " + this.IP + " | DB: " + this.DB + " | UN: " + this.UN + " | PW: " + this.PW);
  27. System.out.println(" > HT: " + this.HT);
  28. System.out.println(" > DDS: " + this.conn);
  29. this.stmt = this.conn.createStatement();
  30. } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException var2) {
  31. System.out.println("[ERROR] : " + var2);
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement