2
votes

I have installed tomcat on centos and deployed a java web application. I'm using mysql db. Everyday in the morning when I try to login as first user, it gieves me the following error:

Your login attempt was not successful, try again. Reason: org.hibernate.exception.JDBCConnectionException: The last packet successfully received from the server was 66,913,221 milliseconds ago. The last packet sent successfully to the server was 66,913,221 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.

After this, When I try to relogin, it allows me to do so.

I have include the following in my context.xml

<Resource name="jdbc/CAR" auth="Container" type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="30000"
           username="root" password="" driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://130.1.18.2:3306/car" validationQuery="SELECT 1" testOnBorrow = true/>

Any help on this, I would appreciate. Thanks

3

3 Answers

2
votes

Try to add autoReconnect=true parameter to the jdbc string to keep it alive when not receiving packets. In your case it would be

    jdbc:mysql://130.1.18.2:3306/car?autoReconnect=true
1
votes

or if you can, you can change to other database pool. I has the same problem before, and the autoReconnect not work for me. Now I am using HikariCP. this problem gone.

0
votes
autoReconnect=true 

is not working as per my knowledge, Mysql having its own connection closure timeout. ORM will mark it as stale connection if Mysql closes the connection.