Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. package net.maschinenmc.lobby.mysql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. import org.bukkit.Bukkit;
  8.  
  9. public class MySQL {
  10. private Connection connection;
  11.  
  12. public static String host;
  13. public static String port;
  14. public static String database;
  15. public static String username;
  16. public static String password;
  17.  
  18. public void mysqlSetup() {
  19. MySQLFile file = new MySQLFile();
  20. file.setStandart();
  21. file.readData();
  22.  
  23. try {
  24. synchronized (this) {
  25. if(getConnection() != null && !getConnection().isClosed()) {
  26. return;
  27. }
  28.  
  29. Class.forName("com.mysql.jdbc.Driver");
  30. setConnection(DriverManager.getConnection("jdbc:mysql://" + MySQL.host + ":" + MySQL.port + "/" + MySQL.database, MySQL.username, MySQL.password));
  31. Bukkit.getConsoleSender().sendMessage("MYSQL VERBUNDEN");
  32. }
  33. }catch(SQLException e) {
  34. e.printStackTrace();
  35. }catch(ClassNotFoundException e) {
  36. e.printStackTrace();
  37. }
  38.  
  39. }
  40.  
  41. public Connection getConnection() {
  42. return connection;
  43. }
  44.  
  45. public void setConnection(Connection connection) {
  46. this.connection = connection;
  47. }
  48.  
  49.  
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement