Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. package de.teamsoul.main.mysql;
  2.  
  3. import java.sql.*;
  4.  
  5. public class mysql {
  6. private static Connection connection;
  7. @SuppressWarnings("unused")
  8. private static Statement command;
  9. @SuppressWarnings("unused")
  10. private static ResultSet data;
  11.  
  12. public static void connect() {
  13. if (!isConnected()) {
  14. try {
  15. connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/teamspeak_bot4.0","admin", "gDSifdsbG843H2jwrd481jkd&kwsZs");
  16.  
  17.  
  18. PreparedStatement ps_supports = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Supports (Name VARCHAR(30), UID VARCHAR(50), Supports INT(255), lastSupport VARCHAR(30))");
  19. PreparedStatement ps_news = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS News (Description VARCHAR(255), Date VARCHAR(50))");
  20. PreparedStatement ps_logouttime = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS LogoutTime (Name VARCHAR(30), UID VARCHAR(50), Time INT(255))");
  21.  
  22. PreparedStatement ps_surveysys = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS SurveySystem (tag VARCHAR(30), text TEXT(500), ifActivated BOOLEAN, yes INT(40), no INT(40))");
  23. PreparedStatement ps_surveysys_participation = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS SurveySystem_participation (uid VARCHAR(50))");
  24.  
  25. PreparedStatement ps_CoinSystem = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS CoinSystem (Coins INT(255),Name VARCHAR(30),UID VARCHAR(60), DailyCoinsAvailable BOOLEAN)");
  26.  
  27.  
  28. ps_supports.executeUpdate();
  29. ps_news.executeUpdate();
  30. ps_logouttime.executeUpdate();
  31.  
  32. ps_surveysys_participation.executeUpdate();
  33. ps_surveysys.executeUpdate();
  34.  
  35. ps_CoinSystem.executeUpdate();
  36.  
  37. System.out.println(" | MySQL Verbindung hergestellt.");
  38. } catch (SQLException e) {
  39. e.printStackTrace();
  40. }
  41. }
  42. }
  43.  
  44. public static void disconnect() {
  45. if (isConnected()) {
  46. try {
  47. connection.close();
  48. System.out.println(" | MySQL Verbindung beednet.");
  49. } catch (SQLException e) {
  50. e.printStackTrace();
  51. }
  52. }
  53. }
  54.  
  55. public static Boolean isConnected() {
  56. return ( connection == null ? false : true);
  57. }
  58.  
  59. public static Connection getConnection() {
  60. return connection;
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement