MySQL closed connection - How to fix it?

Discussion in 'Plugin Development' started by CraftRay, Apr 21, 2016.

Thread Status:
Not open for further replies.
  1. Why my connection with MySQL was closed, when none player dont join to server and server was empty for a long time? How to fix it?

    Code:
     com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 70 501 576 milliseconds ago.  The last packet sent successfully to the server was 70 501 576 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    [19:06:21] [Server thread/WARN]:     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [19:06:21] [Server thread/WARN]:     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    [19:06:21] [Server thread/WARN]:     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    [19:06:21] [Server thread/WARN]:     at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3348)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1967)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1362)
    [19:06:21] [Server thread/WARN]:     at me.xcraftrayx.pl.MySQL.addUser(MySQL.java:231)
    [19:06:21] [Server thread/WARN]:     at me.xcraftrayx.pl.Main.playerJoin(Main.java:55)
    [19:06:21] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [19:06:21] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [19:06:21] [Server thread/WARN]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [19:06:21] [Server thread/WARN]:     at java.lang.reflect.Method.invoke(Method.java:497)
    [19:06:21] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298)
    [19:06:21] [Server thread/WARN]:     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [19:06:21] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509)
    [19:06:21] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:494)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.PlayerList.c(PlayerList.java:265)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.PlayerList.a(PlayerList.java:152)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.LoginListener.c(LoginListener.java:119)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.LoginListener.a(LoginListener.java:44)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:189)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490)
    [19:06:21] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628)
    [19:06:21] [Server thread/WARN]: Caused by: java.net.SocketException: Przerwany potok
    [19:06:21] [Server thread/WARN]:     at java.net.SocketOutputStream.socketWrite0(Native Method)
    [19:06:21] [Server thread/WARN]:     at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    [19:06:21] [Server thread/WARN]:     at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    [19:06:21] [Server thread/WARN]:     at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    [19:06:21] [Server thread/WARN]:     at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    [19:06:21] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3329)
    [19:06:21] [Server thread/WARN]:     ... 26 more
     
  2. Offline

    mcdorli

    Maybe read the first line...
     
    Zombie_Striker and CraftRay like this.
  3. Offline

    Konato_K

    @CraftRay Connections time out, just open it again. (If the server is going to be empty for that long you should close it anyway)
     
  4. Offline

    mine-care

    Also, make sure you run this asynchronously. You don't want to wait for responses form the SQL server on the main thread!
     
  5. Offline

    Badwolf330

    @CraftRay

    Code:
    String connectionURL = "jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database + "?autoReconnect=true";
    
     
Thread Status:
Not open for further replies.

Share This Page