Error:
MySQL first time the next morning to connect the super-times wrong,
Com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link Failure
Reason:
The above problem is caused by the configuration of the MYSQL5 database. MySQL5 the wait time (Wait_timeout, interactive_timeout) of its connection by default to 8 hours. In its client program, you can view its values like this:
Mysql> show global variables like ' wait_timeout ';mysql> show global variables like ' interactive_timeout ';
If the database connection (java.sql.Connection) is in a waiting state for wait_timeout seconds, MYSQL5 closes the connection. At this point, your Java app's connection pool still legitimately holds a reference to that connection. This error is encountered when the connection is used for database operations. This explains why my program cannot log on the next day.
Workaround:
In My.ini (Windows) or/ETC/MY.CNF (Linux), under [Mysqld], add:
wait_timeout=31536000interactive_timeout=31536000
Such as:
Restart MySQL to see the timeout setting again:
[Email protected]/]# /etc/init.d/mysqld restart
...mysql> SHOW GLOBAL VARIABLES like ' interactive_timeout '; +---------------------+----------+| Variable_name | Value |+---------------------+----------+| interactive_timeout | 31536000 |+---------------------+----------+1 Row in Set (0.00 sec) mysql> Show global variables like ' wait_timeout '; +---------------+----------+| variable_name | Value |+---------------+----------+| wait_timeout | 31536000 |+---------------+----------+1 row in Set (0.00 Sec
MySQL 5.1 exceeds the default 8-hour idle Time workaround (Error: Com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link Failure)