Can I use the isValid(0) function to check whether the connection is still active (alive)?
I am getting following exception :
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received from the server was milliseconds ago.
The last packet sent successfully to the server was milliseconds ago, which 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 can’t increase the ‘wait_timeout’ value.
Also I tried with autoReconnect=true but I need to handle the exception anyway.
I got to know about the isValid() function.
But I couldn’t understand what kind of validity it checks.
Would using isValid(0) help me solve timeout problem?
According to the doc,
isValidis required to run “a query”, so it should be useful.Seems like something your connection pool should be doing for you…