title: MySQLNonTransientConnectionException/CommunicationsException when validation is true in domain.xml?
body: <p>Setup: Glassfish 3x, Java EE, EclipseLink.</p>
  
  <p>jdbc connection pool config (from domain.xml):</p>
  
  <pre><code>&lt;jdbc-connection-pool validation-table-name="dummy" pool-resize-quantity="5" max-pool-size="300" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" wrap-jdbc-objects="false" res-type="javax.sql.XADataSource" steady-pool-size="25" name="mysql_bazaarify_rootPool" is-connection-validation-required="true" non-transactional-connections="true" validate-atmost-once-period-in-seconds="60"&gt;
        &lt;property name="URL" value="jdbc:mysql://demodb.mydb.com:3306/database?zeroDateTimeBehavior=convertToNull&amp;amp;useUnicode=yes"&gt;&lt;/property&gt;
  </code></pre>
  
  <p>Getting CommunicationsException infrequently for different queries.
  I have configured for connections to be validated before use with 60 seconds of validity.
  wait_time on sql server is 8 hours.</p>
  
  <p>Still I am seeing below error in my logs (~50 times a day)
  Exception Trace:</p>
  
  <pre><code>Internal Exception: 
      com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
      Error Code: 0
      ....
      Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
      The last packet successfully received from the server was 56,688,227 milliseconds ago.  
      The last packet sent successfully to the server was 56,688,227 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: Connection timed out
          at java.net.SocketOutputStream.socketWrite0(Native Method)
          at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
          at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
          at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
          at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
          at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3832)
          ... 140 more
  </code></pre>
  
  <p>My question is, when I have set for connection to be validated (every 60 seconds), is it possible that I get a stale/broken connection from connection pool which says that the last communication with mysql was (>60seconds) ago?</p>
  
  <p>Shouldn't the connection be validated until a healthy one is returned from the pool? Are these exceptions normal with the settings I have configured?</p>
  
  <p>P.S.
  I observed that in all such failures, the milliseconds ago value reported is always >8 hours. Does that help deduce anything?</p>