Reputation: 3
I have this error:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received from the server was 54,607,614 milliseconds ago.
The last packet sent successfully to the server was 54,607,614 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.
But I don't know what's the error in my Programm, I have autoReconnect=true
... :
connection = DriverManager.getConnection(
"jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useSSL=false", username, password
);
Upvotes: 0
Views: 3385
Reputation: 658
This is warning message, that no sql commands have been send over specified period to the Mysql server. JDBC can do auto reconnect on such event.
Add also parameter
cmaxReconnets=5
to try to reconnect 5 times before give up. Also there is parameter for initial timeout before retry
initialTimeout=1
You can add those to properties when obtaining connection.
DriverManager.getConnection(connectionString, properties)
Upvotes: 2