SHARE
TWEET

Untitled

a guest Jun 16th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package MySQL;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.SQLException;
  7.  
  8.  
  9.  
  10. public class MySQL {
  11.  
  12.     public static String host = "mysql.mc-host24.de";
  13.     public static String database = "coins";
  14.     public static String username = "db_111737";
  15.     public static String password = "4660f7b65e";
  16.     public static Connection con;
  17.    
  18.     public static void connect() {
  19.         if(!isConnected()) {
  20.             try {
  21.                 con = DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database, username, password);
  22.                 System.out.println(main.main.prefix + "§c MySQl§7 verbunden.");
  23.             } catch (SQLException e) {
  24.                 // TODO Auto-generated catch block
  25.                 e.printStackTrace();
  26.             }
  27.         }
  28.        
  29.     }
  30.    
  31.     public static void disconnect() {
  32.         if(isConnected()) {
  33.             try {
  34.                 con.close();
  35.             } catch (SQLException e) {
  36.                 // TODO Auto-generated catch block
  37.                 e.printStackTrace();
  38.             }
  39.             System.out.println(main.main.prefix + "§c MySQl§7 getrennt.");
  40.         }
  41.     }
  42.    
  43.     public static boolean isConnected(){
  44.         return (con != null);
  45.     }
  46.     public static void createTable() {
  47.         try {
  48.             PreparedStatement st = con.prepareStatement("CREATE TABLE IF NOT EXISTS coinsTable (UUID VARCHAR(100), coins INT(16))");
  49.             st.executeUpdate();
  50.            
  51.            
  52.         } catch (SQLException e) {
  53.             // TODO Auto-generated catch block
  54.             e.printStackTrace();
  55.         }
  56.     }
  57.    
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top