Advertisement
theTrixxter

MySQL class

Jan 29th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package com.theTrixxter.mysql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. import org.bukkit.plugin.Plugin;
  8.  
  9. public class MySQL extends database{
  10. public String user, database, password, port, hostname;
  11.  
  12. public MySQL(Plugin plugin, String hostname, String port, String database, String user, String password) {
  13. super(plugin);
  14. this.user = user;
  15. this.database = database;
  16. this.password = password;
  17. this.port = port;
  18. this.hostname = hostname;
  19. }
  20.  
  21. @Override
  22. public Connection openConnection() throws SQLException,
  23. ClassNotFoundException{
  24. if(checkConnection()){
  25. return con;
  26. }
  27. Class.forName("com.mysql.jdbc.Driver");
  28. con = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
  29. return con;
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement