Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class MySQL {
  2.  
  3. public static Connection con;
  4.  
  5.  
  6. public static void connect(){
  7. if(!isConnected()){
  8. try {
  9. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/coins?autoReconnect=true",
  10. "root", "mixnix01");
  11. Bukkit.getConsoleSender().sendMessage("§aMySQl verbunden!");
  12. } catch (SQLException e) {
  13. e.printStackTrace();
  14. }
  15. }
  16. }
  17.  
  18. public static void disconnect(){
  19. if(isConnected()){
  20. try {
  21. con.close();
  22. } catch (SQLException e) {
  23. e.printStackTrace();
  24. }
  25. Bukkit.getConsoleSender().sendMessage("§4MySQL Verbindung getrennt");
  26. }
  27. }
  28.  
  29. public static boolean isConnected(){
  30. return (con != null);
  31. }
  32.  
  33. public static void createTable(){
  34. try {
  35. con.prepareStatement("CREATE TABLE IF NOT EXISTS coinTable (UUID VARCHAR(100), coins INT(16))").executeUpdate();
  36. } catch (SQLException e) {
  37. e.printStackTrace();
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement