Solved Error executing a MySQL query

Discussion in 'Spigot Plugin Development' started by OscarDali, May 27, 2018.

Thread Status:
Not open for further replies.
  1. When I try to place data or obtain them I get this error:
    Code (Text):
    [21:10:25 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.
    [21:10:25 WARN]:        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [21:10:25 WARN]:        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [21:10:25 WARN]:        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [21:10:25 WARN]:        at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [21:10:25 WARN]:        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    [21:10:25 WARN]:        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
    [21:10:25 WARN]:        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
    [21:10:25 WARN]:        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2186)
    [21:10:25 WARN]:        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2219)
    [21:10:25 WARN]:        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2014)
    [21:10:25 WARN]:        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    [21:10:25 WARN]:        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    [21:10:25 WARN]:        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [21:10:25 WARN]:        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [21:10:25 WARN]:        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [21:10:25 WARN]:        at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [21:10:25 WARN]:        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    [21:10:25 WARN]:        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
    [21:10:25 WARN]:        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    [21:10:25 WARN]:        at java.sql.DriverManager.getConnection(Unknown Source)
    [21:10:25 WARN]:        at java.sql.DriverManager.getConnection(Unknown Source)
    [21:10:25 WARN]:        at mx.megacraft.mysterybox.database.MySQL.openConnection(MySQL.java:58)
    [21:10:25 WARN]:        at mx.megacraft.mysterybox.database.MySQLStats.getUsersInDataBase(MySQLStats.java:30)
    [21:10:25 WARN]:        at mx.megacraft.mysterybox.MysteryBox.onEnable(MysteryBox.java:25)
    [21:10:25 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    [21:10:25 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    [21:10:25 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:752)
    [21:10:25 WARN]:        at org.bukkit.Bukkit.reload(Bukkit.java:525)
    [21:10:25 WARN]:        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27)
    [21:10:25 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
    [21:10:25 WARN]:        at java.lang.Thread.run(Unknown Source)
    [21:10:25 WARN]: Caused by: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
    [21:10:25 WARN]:        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    [21:10:25 WARN]:        at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    [21:10:25 WARN]:        at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    [21:10:25 WARN]:        at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    [21:10:25 WARN]:        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    [21:10:25 WARN]:        at java.net.PlainSocketImpl.connect(Unknown Source)
    [21:10:25 WARN]:        at java.net.SocksSocketImpl.connect(Unknown Source)
    [21:10:25 WARN]:        at java.net.Socket.connect(Unknown Source)
    [21:10:25 WARN]:        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
    [21:10:25 WARN]:        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
    [21:10:25 WARN]:        ... 33 more
    [21:10:25 WARN]: java.lang.NullPointerException
    [21:10:25 WARN]:        at mx.megacraft.mysterybox.database.MySQLStats.getUsersInDataBase(MySQLStats.java:21)
    [21:10:25 WARN]:        at mx.megacraft.mysterybox.MysteryBox.onEnable(MysteryBox.java:25)
    [21:10:25 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    [21:10:25 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    [21:10:25 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:752)
    [21:10:25 WARN]:        at org.bukkit.Bukkit.reload(Bukkit.java:525)
    [21:10:25 WARN]:        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27)
    [21:10:25 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648)
    [21:10:25 WARN]:        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
    [21:10:25 WARN]:        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
    [21:10:25 WARN]:        at java.lang.Thread.run(Unknown Source)

    I do not know what the problem is, creating the database creates it perfectly
     
  2. Serializator

    Supporter

    Please post the code that you use to connect to your database.
     
  3. Code (Java):
        public void createConection() {
            FileConfiguration config = ConfigManager.get().getConfig();
            if(!config.getBoolean("MySQL.Enable")) {
                return;
            }
            host = config.getString("MySQL.Host");
            port = config.getInt("MySQL.Port");
            database = config.getString("MySQL.DataBase");
            username = config.getString("MySQL.UserName");
            password = config.getString("MySQL.Password");
            try {  
                openConnection();
                statement = connection.createStatement();
                statement.executeUpdate("CREATE TABLE IF NOT EXISTS Players (UUID VARCHAR(36), Nick VARCHAR(20), BN_Basics INTEGER, BN_Rares INTEGER, " +
                "BN_Epics INTEGER, BN_Legendary INTEGER, BO_Basics INTEGER, BO_Rares INTEGER, BO_Epics INTEGER, BO_Legendary INTEGER, PRIMARY KEY(UUID))");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
     
        public void openConnection() throws SQLException, ClassNotFoundException {
            if (connection != null && !connection.isClosed()) {
                return;
            }
     
            synchronized (this) {
                if (connection != null && !connection.isClosed()) {
                    return;
                }
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection("jdbc:mysql://" + this.host+ ":" + this.port + "/" + this.database, this.username, this.password);
            }
        }
     
  4. Serializator

    Supporter

    What do you use as host and port?
     
  5. electronicboy

    IRC Staff

    provide the full log file, more than likely the error is described much better further up in the logs
     
  6. Code (Java):
    MySQL:
      Enable: true
      Host: 127.0.0.1
      Port: 3306
      DataBase: ******
      UserName: *****
      Password: *****
    Code (YAML):
    [21:05:20] [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.
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2186)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2219)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2014)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    [21:05:20] [Server thread/WARN]
    :    at java.sql.DriverManager.getConnection(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.sql.DriverManager.getConnection(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.database.MySQL.openConnection(MySQL.java:58)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.database.MySQL.createConection(MySQL.java:36)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.MysteryBox.onEnable(MysteryBox.java:24)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:752)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.Bukkit.reload(Bukkit.java:525)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.Thread.run(Unknown Source)
    [21:05:20] [Server thread/WARN]
    : Caused by: java.net.ConnectException: Connection refused: connect
    [21:05:20] [Server thread/WARN]
    :    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    [21:05:20] [Server thread/WARN]
    :    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.PlainSocketImpl.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.SocksSocketImpl.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.Socket.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
    [21:05:20] [Server thread/WARN]
    :    ... 33 more
    [21:05:20] [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.
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2186)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2219)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2014)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    [21:05:20] [Server thread/WARN]
    :    at java.sql.DriverManager.getConnection(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.sql.DriverManager.getConnection(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.database.MySQL.openConnection(MySQL.java:58)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.database.MySQLStats.getUsersInDataBase(MySQLStats.java:30)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.MysteryBox.onEnable(MysteryBox.java:25)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:752)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.Bukkit.reload(Bukkit.java:525)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.Thread.run(Unknown Source)
    [21:05:20] [Server thread/WARN]
    : Caused by: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
    [21:05:20] [Server thread/WARN]
    :    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    [21:05:20] [Server thread/WARN]
    :    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.PlainSocketImpl.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.SocksSocketImpl.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at java.net.Socket.connect(Unknown Source)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
    [21:05:20] [Server thread/WARN]
    :    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
    [21:05:20] [Server thread/WARN]
    :    ... 33 more
    [21:05:20] [Server thread/WARN]
    : java.lang.NullPointerException
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.database.MySQLStats.getUsersInDataBase(MySQLStats.java:21)
    [21:05:20] [Server thread/WARN]
    :    at mx.megacraft.mysterybox.MysteryBox.onEnable(MysteryBox.java:25)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:752)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.Bukkit.reload(Bukkit.java:525)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648)
    [21:05:20] [Server thread/WARN]
    :    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
    [21:05:20] [Server thread/WARN]
    :    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
    [21:05:20] [Server thread/WARN]
    :    at java.lang.Thread.run(Unknown Source)
     
  7. electronicboy

    IRC Staff

    Your mysql server isn't accepting connections on whatever you've told it to connect to

    or better yet, you managed to really upset something. try using localhost, instead of 127...
     
  8. Serializator

    Supporter

    Are you certain that you have a MySQL database running on your local machine on port 3306?

    If, for example, you have your MySQL database running as a Docker container and you use Docker Toolbox for Windows you'll have to use the IP of the virtual box to connect to the database or have the virtual box that Docker Toolbox for Windows runs on forward port 3306 from the virtual box to port 3306 on the host.
     
  9. Unfortunately it is the same error when using LocalHost

    I'm using XAMPP says it runs on port 3306 and creates the database, but to connect to the admin I use http://localhost:8080/phpmyadmin
     
  10. Just by chance will not be something wrong in my code?, Since I believe the database perfectly

    Code (Java):
        public void getUsersInDataBase() {
            try {
                Statement stmt = MySQL.get().connection.createStatement();
                resulSet = stmt.executeQuery("SELECT * FROM Players");
                Utils.get().sendMessageToConsole("&c&lUsers in db: ");
                while(resulSet.next()) {
                    Utils.get().sendMessageToConsole("&a" + resulSet.getString(1));
                }
                stmt.close();
            } catch (Exception e) {
              try {
                  MySQL.get().openConnection();
              }
              catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              }
              catch (SQLException e1) {
                e1.printStackTrace();
              }
              e.printStackTrace();
            }
        }
     
  11. Strahan

    Benefactor

    Localhost and 127.0.0.1 are synonymous, that's fine. The 8080 for the administration is for the web server connection, it has nothing to do with connecting to MySQL.

    Is this Windows? If so, open a command prompt and do netstat -a -n|find "3306" and see if it shows as listening.
     
  12. Code (YAML):
      TCP    127.0.0.1:3306         0.0.0.0:0              LISTENING
      TCP    127.0.0.1:3306         127.0.0.1:19301        ESTABLISHED
     
  13. Serializator

    Supporter

    If it's listening, are you certain that your configuration is read out properly?
    Try to print out the host, port and such and possibly even the JDBC connection url.
     
  14. [​IMG]
    I send you a photo so you can see it better and the user and password if it's ok​
     
  15. Serializator

    Supporter

    What did you cross out at the end of the JDBC url?
     
  16. Username and password, the truth is nothing important, the password and user is "android" xD is local the db so it does not matter

    Code (YAML):
    [22:22:23 INFO]: URL: jdbc:mysql://127.0.0.1:3306/spigotandroidandroid
     
  17. Serializator

    Supporter

    Can you send the log statement that prints out the URL?
     
  18. To print it use this because it is separated by ","
    Code (Java):
    "jdbc:mysql://" + this.host+ ":" + this.port + "/" + this.database + this.username + this.password
    I do not know if you mean that sorry
     
  19. Serializator

    Supporter

    Asked because I thought something went wrong with the concatenation because your username and password got appended to the URL, but that's just the way you logged it, alright.
     
  20. Will it be something wrong with my computer?, I have SQL Server too, I do not know if that affects something
     
Thread Status:
Not open for further replies.