How to resolve the problem of MySQL 8 hours after idle connection timeout

Source: Internet
Author: User
Tags valid

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.