Advertisement
Guest User

MySQL.java

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