Guest User

Untitled

a guest
Jan 1st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1.  
  2. package de.nachgesalzt.untils;
  3.  
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.SQLException;
  7.  
  8. import org.bukkit.Bukkit;
  9.  
  10. import de.nachgesalzt.data.Data;
  11.  
  12. public class MySQL {
  13.  
  14. public static Connection con;
  15.  
  16. public static void connect(){
  17. if(!isConnected()){
  18. try {
  19. con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/Geld?autoReconnect=true", "root", "qwertz125");
  20. Bukkit.getConsoleSender().sendMessage(Data.pr + "§aDie MySQL Verbindung wurde auf gebaut!");
  21. } catch (SQLException e) {
  22. // TODO Auto-generated catch block
  23. e.printStackTrace();
  24. }
  25. }
  26. }
  27. public static void disconnect() {
  28. if(isConnected()){
  29. try {
  30. con.close();
  31. Bukkit.getConsoleSender().sendMessage(Data.pr + "§cDie MySQL Verbindung wurde getrennt!");
  32. } catch (SQLException e) {
  33. // TODO Auto-generated catch block
  34. e.printStackTrace();
  35. }
  36. }
  37. }
  38. public static boolean isConnected() {
  39. return (con != null);
  40. }
  41.  
  42.  
  43. }
Add Comment
Please, Sign In to add comment