I found a rule in my project to solve the connection timeout problem of mysql for 8 hours. If the connection between an application and a database is established for more than 8 hours, if the application does not access the database, the database will be disconnected. In this case, an exception is thrown. 1. Generally, the "autoReconnect = true" option is added to the database connection string. However, this is only valid for versions earlier than MySQL 4. It is invalid in the latest mysql. In fact, there is also a simple way to solve this problem, that is, to modify the mysql startup parameters. By default, the timeout time of mysql is 28800 seconds, which is exactly 8 hours. You can add a value of 0. You can also add this parameter to the "my. ini" file. Mysqld-nt -- default-table-type = innodb -- interactive_timeout = 288000 2. Set wait_timeout of mysql to 31536000 (one year ). Www.2cto.com mysql> show variables; | wait_timeout | 28800 | interactive_timeout | 28800 "my. ini" file modifying this parameter [mysqld] wait_timeout = 31536000interactive_timeout = 31536000 restart the service, OK! Author Cai lei