Note that there are some explanatory texts on larger screens.

plurals
  1. POStale connections, validationQuery does not fix
    text
    copied!<p>I am getting the dreaded MySQL JDBC stale connection exceptions:</p> <pre><code>Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed. Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 243,263,541 milliseconds ago. The last packet sent successfully to the server was 243,263,541 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. </code></pre> <p>It seems like everyone agrees that this is fixed by using validationQuery + testOnBorrow, but this is not solving the problem.</p> <p>I am using the following software MySQL 5.1.41-3ubuntu12.10 Connector/J 5.1.18 Tomcat 6.0.24</p> <p>Here is how the connection is defined in server.xml, we are using the tomcat-dbcp to pool the connections.</p> <pre><code> &lt;Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" factory="org.apache.commons.dbcp.BasicDataSourceFactory" logAbandoned="true" maxActive="75" maxIdle="20" maxWait="10000" name="jdbc/jndiname" password="password" removeAbandoned="true" removeAbandonedTimeout="60" validationQuery="/* ping */SELECT 1" testOnBorrow="true" testOnReturn="true" timeBetweenEvictionRunsMillis="10000" testWhileIdle="true" scope="Shareable" type="javax.sql.DataSource" url="jdbc:mysql://host:3306/schema" username="username" /&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload