Q: How to solve MySQL 8 hours after the idle connection timeout problem?
A: When the application and the database connection, if more than 8 hours, the application sentence will not access the database, the database will be a broken connection phenomenon. The second access will throw an exception, as follows:
Communications link failure due to
underlying exception:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
STACKTRACE:
java.io.EOFException
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1913)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2304)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2803)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
...
The general solution is to add the "autoreconnect=true" option in the database connection string. However, this is only valid for previous versions of MYSQL4. is not valid in the latest MySQL. In fact, there is a simple way to solve this problem is to modify the MySQL startup parameters. By default, MySQL's timeout time is 28,800 seconds, just 8 hours, adding a 0 is OK.
This parameter can also be added to the "My.ini" file in the same vein.
mysqld-nt --default-table-type=innodb --interactive_timeout=288000