title: Tomcat JDBC Conencton Pool + MySQL gives "Broken pipe" problems, even with connection validation
body: <p>I'm fighting with configuring Tomcat JDBC Connection Pool to achieve reliability. Current issue is that in test environment I have such scanerio in webapp:</p>
  
  <ul>
  <li>day 1: everything works fine</li>
  <li>day 2: webapp cannot comunicate with MySQL for several hours, lot of "Broken pipe" in logs</li>
  <li>day 3: suprisingly, everything works fine again (without ingerention or restart)</li>
  </ul>
  
  <p>I have configured <code>validationInterval</code>, <code>validationQuery</code>, <code>validationTimeout</code>. This is my data source config:</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
      destroy-method="close"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="username" value="${dbUser}" /&gt;
      &lt;property name="password" value="${dbPass}" /&gt;
      &lt;property name="url" value="${dbUrl}" /&gt;
      &lt;property name="defaultAutoCommit" value="false" /&gt;
      &lt;property name="defaultTransactionIsolation"&gt;
      &lt;util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE" /&gt;
      &lt;/property&gt;
  
      &lt;property name="maxActive" value="300" /&gt;
      &lt;property name="maxIdle" value="25" /&gt;
      &lt;property name="initialSize" value="5" /&gt;
  
      &lt;property name="validationInterval" value="5000" /&gt;
      &lt;property name="validationQuery" value="SELECT 1"/&gt;
      &lt;property name="validationQueryTimeout" value="3" /&gt;
  
      &lt;property name="minIdle" value="5" /&gt;
      &lt;property name="initSQL" value="SET time_zone = '+00:00';" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I don't have <code>autoReconnect=true</code> parameter in connection URL, only UTF8 encoding.</p>
  
  <p>The exact error is:</p>
  
  <pre><code>Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
  The last packet successfully received from the server was 38,700,615
  milliseconds ago.  The last packet sent successfully to the server was
  38,700,615 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.
  Caused by: java.net.SocketException: Broken pipe
  </code></pre>