Mysql: Communications link failure solution, failure
-
Mysql: Communications link failure solves the problem of connecting to MySQL using Connector/J. After the program runs for a long time, the following error will be reported: Communications link failure, the last packet successfully received from the server was *** millisecond ago. the last packet successfully sent to the server was *** millisecond ago. The error will also prompt you to modify wait_timeout or use the autoReconnect attribute of ctor/J to avoid this error. The default "wait_timeout" of the MySQL server is 28800 seconds, that is, 8 hours. This means that if the idle time of a connection exceeds 8 hours, MySQL will automatically disconnect the connection, the connection pool considers the connection to be valid (because the connection is not verified). When the application applies to use the connection, the above error is reported. There are two solutions: one is to modify my. cnf:
Wait_timeout = 31536000 interactive_timeout = 31536000 change the expiration time to one year. Second, add the parameter & autoReconnect = true & failOverReadOnly = false to the connection URL.