Guest User

Untitled

a guest
Jun 2nd, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. package me.trow.TGEssentials.MySQL;
  2.  
  3. import java.sql.*;
  4.  
  5. public class MySQL extends Database
  6. {
  7. private final String user;
  8. private final String database;
  9. private final String password;
  10. private final String port;
  11. private final String hostname;
  12.  
  13. public MySQL(final String hostname, final String port, final String database, final String username, final String password) {
  14. this.hostname = hostname;
  15. this.port = port;
  16. this.database = database;
  17. this.user = username;
  18. this.password = password;
  19. }
  20.  
  21. @Override
  22. public Connection openConnection() throws SQLException, ClassNotFoundException {
  23. if (this.checkConnection()) {
  24. return this.connection;
  25. }
  26. Class.forName("com.mysql.jdbc.Driver");
  27. return this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
  28. }
  29.  
  30. public String getUser() {
  31. return this.user;
  32. }
  33.  
  34. public String getHostname() {
  35. return this.hostname;
  36. }
  37.  
  38. public String getDatabase() {
  39. return this.database;
  40. }
  41.  
  42. public String getPassword() {
  43. return this.password;
  44. }
  45. }
Add Comment
Please, Sign In to add comment