Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package me.MySQL;
  2.  
  3.  
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.SQLException;
  7.  
  8. import org.bukkit.Bukkit;
  9.  
  10.  
  11.  
  12. import me.BanSystem.Main;
  13.  
  14. public class MySQL {
  15.  
  16. public static String username;
  17. public static String password;
  18. public static String database;
  19. public static String host;
  20. public static String port;
  21. public static Connection con;
  22.  
  23.  
  24. public static void connnect() {
  25. if(!isConnected()) {
  26. try {
  27. con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
  28. Bukkit.getConsoleSender().sendMessage(Main.getInstance().prefix + "§cMySQL Verbindung aufgebaut!");
  29. } catch (SQLException e) {
  30.  
  31. e.printStackTrace();
  32. }
  33.  
  34.  
  35. }
  36.  
  37. }
  38.  
  39. public static void close() {
  40. if(isConnected()) {
  41. try {
  42. con.close();
  43. Bukkit.getConsoleSender().sendMessage(Main.getInstance().prefix + "§cMySQL Verbindung geschlossen!");
  44. } catch (SQLException e) {
  45. e.printStackTrace();
  46. }
  47.  
  48. }
  49.  
  50.  
  51. }
  52.  
  53. public static boolean isConnected() {
  54. return con != null;
  55.  
  56. }
  57.  
  58. public static void createTabel() {
  59. /*
  60. *
  61. * Syntax: Spielername, UUID, Ende, Grund;
  62. *
  63. */
  64. if(isConnected());
  65. try {
  66. con.createStatement().executeUpdate("CREATE TABEL IF NOT EXISTS BannendPlayers (Spielername VARCHAR(100), UUID VARCHAR(100), Ende VARCHAR(100), Grund VARCHAR(100))");
  67. } catch (SQLException e) {
  68. e.printStackTrace();
  69. }
  70.  
  71. }
  72.  
  73.  
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement