Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.teamsoul.main.mysql;
- import java.sql.*;
- public class mysql {
- private static Connection connection;
- @SuppressWarnings("unused")
- private static Statement command;
- @SuppressWarnings("unused")
- private static ResultSet data;
- public static void connect() {
- if (!isConnected()) {
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/teamspeak_bot4.0","admin", "gDSifdsbG843H2jwrd481jkd&kwsZs");
- PreparedStatement ps_supports = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Supports (Name VARCHAR(30), UID VARCHAR(50), Supports INT(255), lastSupport VARCHAR(30))");
- PreparedStatement ps_news = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS News (Description VARCHAR(255), Date VARCHAR(50))");
- PreparedStatement ps_logouttime = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS LogoutTime (Name VARCHAR(30), UID VARCHAR(50), Time INT(255))");
- 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))");
- PreparedStatement ps_surveysys_participation = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS SurveySystem_participation (uid VARCHAR(50))");
- PreparedStatement ps_CoinSystem = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS CoinSystem (Coins INT(255),Name VARCHAR(30),UID VARCHAR(60), DailyCoinsAvailable BOOLEAN)");
- ps_supports.executeUpdate();
- ps_news.executeUpdate();
- ps_logouttime.executeUpdate();
- ps_surveysys_participation.executeUpdate();
- ps_surveysys.executeUpdate();
- ps_CoinSystem.executeUpdate();
- System.out.println(" | MySQL Verbindung hergestellt.");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void disconnect() {
- if (isConnected()) {
- try {
- connection.close();
- System.out.println(" | MySQL Verbindung beednet.");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static Boolean isConnected() {
- return ( connection == null ? false : true);
- }
- public static Connection getConnection() {
- return connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement