Database Connection timeout

Source: Internet
Author: User
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was43810 seconds ago.The last packet sent successfully to the server was 43810 seconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)        at java.lang.reflect.Constructor.newInstance(Unknown Source)        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3246)        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1917)        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)        at com.mindpro.taxi.call.DBConnection.executeUpdate(DBConnection.java:64)        at com.mindpro.taxi.call.PassengerService$UdpServiceThread.updatePassenger(PassengerService.java:259)        at com.mindpro.taxi.call.PassengerService$UdpServiceThread.run(PassengerService.java:209)Caused by: java.net.SocketException: Software caused connection abort: socket write error        at java.net.SocketOutputStream.socketWrite0(Native Method)        at java.net.SocketOutputStream.socketWrite(Unknown Source)        at java.net.SocketOutputStream.write(Unknown Source)        at java.io.BufferedOutputStream.flushBuffer(Unknown Source)        at java.io.BufferedOutputStream.flush(Unknown Source)        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3227)        ... 10 more

Autoreconnect = true & failoverreadonly = false does not seem to work

Reference: http://blog.csdn.net/mqboss/article/details/6659001

1. according to the error message, you can use the autoreconnect attribute in the jdbc url. In the actual test, autoreconnect = true & failoverreadonly = false is used, but it does not work. Version 5.1 is used, it may be effective only for versions earlier than 4 As mentioned on the Internet.

2. No way. You can only modify MySQL parameters. The maximum value of wait_timeout is 31536000, that is, 1 year. Add the following to my. CNF:

[Mysqld]

Wait_timeout = 31536000

Interactive_timeout = 31536000

The restart takes effect. You need to modify these two parameters at the same time.

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.