Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package net.jlpcrew.lobbyscoreboard;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class MySQL {
  8.  
  9. public static String host = "localhost";
  10. public static String port = "3306";
  11. public static String database = "JLPCrew.net";
  12. public static String username = "root";
  13. public static String password = "2a7d85d2fba3";
  14. public static Connection con;
  15.  
  16. public static void connect() {
  17.  
  18. if(!isConnected()) {
  19.  
  20. try {
  21.  
  22. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/JLPCrew.net?autoReconnect=true", "root", "2a7d85d2fba3");
  23. System.out.println("[LobbySystem - MySQL] Verbindung aufgebaut!");
  24.  
  25. } catch (SQLException e) {
  26.  
  27. e.printStackTrace();
  28.  
  29. }
  30.  
  31. }
  32.  
  33. }
  34.  
  35. public static void disconnect() {
  36.  
  37. if(isConnected()) {
  38.  
  39. try {
  40.  
  41. con.close();
  42. System.out.println("[LobbySystem - MySQL] Verbindung geschlossen!");
  43.  
  44. } catch (SQLException e) {
  45.  
  46. e.printStackTrace();
  47.  
  48. }
  49.  
  50. }
  51.  
  52. }
  53.  
  54. public static boolean isConnected() {
  55.  
  56. return(con == null ? false : true);
  57.  
  58. }
  59.  
  60. public static void createTable() {
  61.  
  62. try {
  63. con.prepareStatement("CREATE TABLE IF NOT EXISTS PunkteSystem (UUID VARCHAR(100), Punkte INT(16))").executeUpdate();
  64. } catch (SQLException e) {
  65. e.printStackTrace();
  66. }
  67.  
  68. }
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement