title: com.mysql.jdbc.exception.jdbc4.CommunicationsException: The last packet successfully received from the server was
body: <p>I have a method that executes in the early morning but jdbc connection tomcat closes by itself and I don't know why and how.</p>
  
  <pre><code>The last packet successfully received from the server was 86.397.130 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3567)
      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3456)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3997)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
      at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2318)
      at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
  </code></pre>
  
  <p>In my <strong>server.xml</strong> I have the context with the resource <code>"autoReconnect=true"</code></p>
  
  <blockquote>
    <p>url="jdbc:mysql://localhost:3306/database?autoReconnect=true"</p>
  </blockquote>
  
  <p>But still does not work. Any help or suggestions?</p>
  
  <p>Thanks.</p>