In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the mysql error Communications link failure how to do, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
First, problems
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureLast packet sent to the server was 12 ms ago. 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.reuseAndReadPacket (MysqlIO.java:3009) at com.mysql. Jdbc.MysqlIO.reuseAndReadPacket (MysqlIO.java:2895) at com.mysql.jdbc.MysqlIO.checkErrorPacket (MysqlIO.java:3438) at com.mysql.jdbc.MysqlIO.sendCommand (MysqlIO.java:1951) at com.mysql.jdbc.MysqlIO.sqlQueryDirect (MysqlIO.java:2101) at com.mysql.jdbc.ConnectionImpl.execSQL (ConnectionImpl.java:2548) at com.mysql.jdbc.ConnectionImpl.execSQL (ConnectionImpl.java:2477) at com.mysql.jdbc.StatementImpl.executeQuery ( StatementImpl.java:1422) at com.victor_01.Jdbc_test.main (Jdbc_test.java:29) Caused by: java.net.SocketException: Software caused connection abort: recv failed at java.net.SocketInputStream.socketRead0 (Native Method) at java.net.SocketInputStream.socketRead (Unknown Source) at java.net.SocketInputStream.read (Unknown Source) at java.net.SocketInputStream.read (Unknown Source) at com.mysql.jdbc.util.ReadAheadInputStream.fill (ReadAheadInputStream.java:113 ) at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary (ReadAheadInputStream.java:160) at com.mysql.jdbc.util.ReadAheadInputStream.read (ReadAheadInputStream.java:188) at com.mysql.jdbc.MysqlIO.readFully (MysqlIO.java:2452) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket (MysqlIO.java:2906)... 8 more
II. Steps to solve the problem
1. Check that your database connection address (url in the configuration file) is correct.
two。 It may be caused by the configuration of the mysql5 database. Mysql5 defaults the wait time (wait_timeout) for its connection to 8 hours. You can view its value in its client program like this:
Mysql > show global variables like 'wait_timeout'; +-+ | Variable_name | Value | +-+-+ | wait_timeout | 28800 | +-+-+ 1 row in set (0.00 sec)
28800 seconds, or 8 hours, if the database connection (java.sql.Connection) has been waiting for a period of wait_timeout seconds, mysql5 closes the connection. At this point, your Java application's connection pool still legally holds a reference to the connection. The above error is encountered when the connection is used for database operations.
Solution:
Previous versions of 2.1.mysql5 could have added "autoReconnect=true" directly to the configuration of the jdbc connection url.
2.2. Change the value of the global variable wait_timeout of mysql to the maximum. Looking at the manual of mysql5, it is found that the maximum values of wait_timeout under windows and linux are 24 and 365 days, respectively.
(1)。 Add a line at the end of the file my.ini: wait_timeout=1814400. (this file is under windows under the installation directory of mysql and / etc/my.ini under linux)
(2)。 Restart mysql.
3. If you have gone through the above steps and your problem is still not solved, it is recommended that you modify the version of the mysql driver in your program.
Thank you for reading this article carefully. I hope the article "what to do about mysql error reporting Communications link failure" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.