MySQL und Plugin Enable Fehler

Discussion in 'Spigot Plugin Help' started by Zocker7000, Feb 4, 2020.

Thread Status:
Not open for further replies.
  1. Guten Tag, ich bin momentan dabei ein Lobbysystem zu programmieren, doch möchte die MySQL kein Tabel erstellen. Ich suche nun schon seit einer Stunde nach den Fehler, doch habe ich ihn noch nicht gefunden.


    Fehlercode:
    Code (Text):
    [19:55:04] [Server thread/INFO]: [LobbySystem] Enabling LobbySystem v1.0
    [19:55:04] [Server thread/INFO]: 3
    [19:55:04] [Server thread/WARN]: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    [19:55:04] [Server thread/WARN]:     at sun.reflect.GeneratedConstructorAccessor65.newInstance(Unknown Source)
    [19:55:04] [Server thread/WARN]:     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    [19:55:04] [Server thread/WARN]:     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    [19:55:04] [Server thread/WARN]:     at sun.reflect.GeneratedConstructorAccessor48.newInstance(Unknown Source)
    [19:55:04] [Server thread/WARN]:     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    [19:55:04] [Server thread/WARN]:     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
    [19:55:04] [Server thread/WARN]:     at java.sql.DriverManager.getConnection(DriverManager.java:664)
    [19:55:04] [Server thread/WARN]:     at java.sql.DriverManager.getConnection(DriverManager.java:247)
    [19:55:04] [Server thread/WARN]:     at we.minehype.lobbyutils.MySQL.connect(MySQL.java:20)
    [19:55:04] [Server thread/WARN]:     at we.minehype.lobbymain.LobbyMain.onEnable(LobbyMain.java:23)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.Bukkit.reload(Bukkit.java:535)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [19:55:04] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
    [19:55:04] [Server thread/WARN]:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    [19:55:04] [Server thread/WARN]:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
    [19:55:04] [Server thread/WARN]:     at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
    [19:55:04] [Server thread/WARN]:     at java.lang.Thread.run(Thread.java:748)
    [19:55:04] [Server thread/WARN]: Caused by: java.net.ConnectException: Connection refused (Connection refused)
    [19:55:04] [Server thread/WARN]:     at java.net.PlainSocketImpl.socketConnect(Native Method)
    [19:55:04] [Server thread/WARN]:     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    [19:55:04] [Server thread/WARN]:     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    [19:55:04] [Server thread/WARN]:     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    [19:55:04] [Server thread/WARN]:     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    [19:55:04] [Server thread/WARN]:     at java.net.Socket.connect(Socket.java:589)
    [19:55:04] [Server thread/WARN]:     at java.net.Socket.connect(Socket.java:538)
    [19:55:04] [Server thread/WARN]:     at java.net.Socket.<init>(Socket.java:434)
    [19:55:04] [Server thread/WARN]:     at java.net.Socket.<init>(Socket.java:244)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
    [19:55:04] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
    [19:55:04] [Server thread/WARN]:     ... 38 more
    [19:55:04] [Server thread/INFO]: 4
    [19:55:04] [Server thread/ERROR]: Error occurred while enabling LobbySystem v1.0 (Is it up to date?)
    java.lang.NullPointerException
        at we.minehype.lobbyutils.MySQL.createTable(MySQL.java:43) ~[?:?]
        at we.minehype.lobbymain.LobbyMain.onEnable(LobbyMain.java:25) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_211]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_211]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_211]
    Main:
    Code (Java):
    package we.minehype.lobbymain;


    import org.bukkit.command.CommandExecutor;
    import org.bukkit.plugin.java.JavaPlugin;

    import we.minehype.commands.CMD_Coins;
    import we.minehype.lobbyutils.LobbyFileManager;
    import we.minehype.lobbyutils.MySQL;
    import we.minehype.lobbyutils.MySQLConfigHandler;

    public class LobbyMain extends JavaPlugin{
       
        @Override
        public void onEnable() {
            saveDefaultConfig();
            LobbyFileManager.createFile();
            MySQLConfigHandler mysqlfile = new MySQLConfigHandler();
           
            mysqlfile.setStandart();
            mysqlfile.readData();
            System.out.println("3");
            MySQL.connect();
            System.out.println("4");
            MySQL.createTable("CREATE TABLE IF NOT EXISTS coins (UUID VARCHAR(100),coins INT(16))");
            System.out.println("5");
           
            registerCommands();
        }
       
        @Override
        public void onDisable() {
           
            MySQL.disconnect();
        }
       
        public void registerCommands() {
            getCommand("coins").setExecutor((CommandExecutor) new CMD_Coins());
        }
       

    }
     
    MySQL-Class:
    Code (Java):
    package we.minehype.lobbyutils;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;

    public class MySQL {

        public static String host;
        public static int port;
        public static String database;
        public static String username;
        public static String password;
        public static Connection con;

        public static void connect() {
            if (!isConnected())
                try {
                    con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database,username, password);
                    System.out.println("MySQL ist Verbunden!");
                } catch (SQLException e) {
                    e.printStackTrace();
                }
        }

        public static void disconnect() {
            if (isConnected())
                try {
                    con.close();
                    System.out.println("MySQL Verbindung getrennt!");
                } catch (SQLException e) {
                    e.printStackTrace();
                }
        }

        public static boolean isConnected() {
            return (con != null);
        }

        public static void createTable(String qry) {
            try {
                PreparedStatement ps = con.prepareStatement(qry);
                ps.executeUpdate();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

    }
    Ich hoffe ihr könnt mir irgendwie helfen.


    Vielen dank im Voraus,
    Lena
     
  2. Its really helpful. Thank you very much.
     
Thread Status:
Not open for further replies.