I read this advice from error message:
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'm using Spring and JPA. Where should I configure Connector/J? (in persistence.xml
, or in entityManagerFactory
spring configuration, or in dateSource
spring configuration, or somewhere else?)
The text describes three solutions to prevent connection aborts:
Configure the connection string with autoReconnect=true
. This is a property of the URL connection string, which works at the driver level. You need to change the connection string in the data source configuration.
url="jdbc:mysql://localhost:3306/confluence?autoReconnect=true"
Increase the timeout. This is normally a property of the database. You can increase this value to see if you get less connection abort.
Configure the connection pool to test the connection validatiy. This is done at the pool, not a the driver level. This will depend on the data source implementation that you use. But it should be configurable in the property of the data source, if you use a pooled one, e.g. c3p0.
Additionnal comments: