Advertisement
Guest User

Untitled

a guest
May 30th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. package BrotGames.HubSystem.Main;
  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.  
  11. public static String username;
  12. public static String password;
  13. public static String database;
  14. public static String host;
  15. public static String port;
  16. public static Connection con;
  17.  
  18. public static void connect() {
  19. if (!isConnected()) {
  20. try {
  21. con = DriverManager.getConnection("jdbc:mysql://" + host + ":"
  22. + port + "/" + database, username, password);
  23. Bukkit.getConsoleSender().sendMessage(
  24. HubSystem.getInstance().pr
  25. + "MySQL Verbindung aufgebaut!");
  26. } catch (SQLException e) {
  27. e.printStackTrace();
  28. }
  29. }
  30. }
  31.  
  32. public static void close() {
  33. if (isConnected()) {
  34. try {
  35. con.close();
  36. Bukkit.getConsoleSender().sendMessage(
  37. HubSystem.getInstance().pr
  38. + "MySQL Verbindung gestoppt!");
  39. } catch (SQLException e) {
  40. e.printStackTrace();
  41. }
  42.  
  43. }
  44. }
  45.  
  46. public static boolean isConnected() {
  47. return con != null;
  48.  
  49. }
  50.  
  51. public static void createTable() {
  52. // Spielername, UUID, Ende, Grund
  53. if (isConnected()) {
  54. try {
  55. con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS BannedPlayers (Spielername VARCHAR(100), UUID VARCHAR(100), Ende VARCHAR(100), Grund VARCHAR(100)");
  56. } catch (SQLException e) {
  57. // TODO Auto-generated catch block
  58. e.printStackTrace();
  59. }
  60. }
  61.  
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement