title: Communications link failure due to: java.io.EOFException
body: <p>My webapp is running on Tomcat 5.5, I declared the datasource in web.xml:</p>
  
  <pre><code>&lt;resource-ref&gt;
      &lt;res-ref-name&gt;jdbc/OrdiniWebDS&lt;/res-ref-name&gt;
      &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
      &lt;res-auth&gt;Container&lt;/res-auth&gt;
      &lt;res-sharing-scope&gt;Shareable&lt;/res-sharing-scope&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p>In context.xml (tomcat conf):</p>
  
  <pre><code>&lt;Resource 
    auth="Container" 
    driverClassName="com.mysql.jdbc.Driver" 
    maxActive="100" 
    maxIdle="30" 
    maxWait="10000" 
    name="jdbc/OrdiniWebDS" 
    password="[mypassword]" 
    type="javax.sql.DataSource" 
    url="jdbc:mysql://[myHost:port]/ordiniweb" 
    username="[myusername]"
   /&gt;
  </code></pre>
  
  <p>The database is a MySql 5.0.
  Everything works well except that sometimes, after several hours of "unuse", at first access I got this Exception:</p>
  
  <pre><code>com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 
  
  ** BEGIN NESTED EXCEPTION ** 
  
  java.io.EOFException
  
  STACKTRACE:
  
  java.io.EOFException
   at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1956)
   at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2368)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2867)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1616)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1708)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:3255)
   at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1293)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1428)
   at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
   at com.blasetti.ordiniweb.dao.OrdiniDAO.caricaOrdine(OrdiniDAO.java:263)
  ...
  ** END NESTED EXCEPTION **
  
  
  
  Last packet sent to the server was 0 ms ago.
   com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2579)
   com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2867)
   com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1616)
   com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1708)
   com.mysql.jdbc.Connection.execSQL(Connection.java:3255)
   com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1293)
   com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1428)
   org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
   com.blasetti.ordiniweb.dao.OrdiniDAO.caricaOrdine(OrdiniDAO.java:263)
  ...
  </code></pre>
  
  <p>I need to refresh and it works well again. Any idea? Thanks.</p>