Expand my Community achievements bar.

SOLVED

DataSourcePool and validation query

Avatar

Level 3

Hi,
I try to use DataSourcePool to connect with MySQL database. And I notice that after long inactivity or database restart connection is closed and first attempt to use it ends with this error message.

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 49,803,911 milliseconds ago.  The last packet sent successfully to the server was 49,803,925 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.

I try to define validation query "Select 1" but I don't see any improvements.
Also have autoReconnect=true and autoReconnectForPools=true in connection url
Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

For testing purposes -- try and write your own OSGi bundle to connect to database. See:

http://helpx.adobe.com/adobe-cq/using/creating-cq-web-application-uses.html

http://helpx.adobe.com/adobe-cq/using/querying-persisting-cq-data-mysql.html

I have noticed in the past -- that I have fewer issues when i write my own connection via an OSGi using JDBC APIs. 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

For testing purposes -- try and write your own OSGi bundle to connect to database. See:

http://helpx.adobe.com/adobe-cq/using/creating-cq-web-application-uses.html

http://helpx.adobe.com/adobe-cq/using/querying-persisting-cq-data-mysql.html

I have noticed in the past -- that I have fewer issues when i write my own connection via an OSGi using JDBC APIs.