Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MySQL {
- public static Connection con;
- public static void connect(){
- if(!isConnected()){
- try {
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/coins?autoReconnect=true",
- "root", "mixnix01");
- Bukkit.getConsoleSender().sendMessage("§aMySQl verbunden!");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void disconnect(){
- if(isConnected()){
- try {
- con.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- Bukkit.getConsoleSender().sendMessage("§4MySQL Verbindung getrennt");
- }
- }
- public static boolean isConnected(){
- return (con != null);
- }
- public static void createTable(){
- try {
- con.prepareStatement("CREATE TABLE IF NOT EXISTS coinTable (UUID VARCHAR(100), coins INT(16))").executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement