当前位置:网站首页>Resolved: JDBC connection to MySQL failed with an error:'The last packet sent successfully to the server was 0 milliseconds ago. '
Resolved: JDBC connection to MySQL failed with an error:'The last packet sent successfully to the server was 0 milliseconds ago. '
2022-06-11 03:08:00 【CSDN Q & A】
First attempt JDBC Connect Mysql, And then keep reporting the error .
Error code :
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:172) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862) at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226) at connection.connectionTest.connectionTest1(connectionTest.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:103) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:149) at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:165) at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:92) at com.mysql.cj.NativeSession.connect(NativeSession.java:152) at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:982) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852) ... 26 moreCaused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394) at java.net.Socket.connect(Socket.java:606) at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:173) at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:66) ... 29 moreOperation results and error reporting contents
Tried to modify the time zone 、 Character set 、wait_timeout And so on. , But it didn't work . Then the driver uses :“mysql-connector-java-8.0.17.jar”, mysql It's also 8.0 Version above , There should be no problem with matching .
url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&userUnicode=true&charsetEncoding=utf-8url=jdbc:mysql://localhost:3306/testdriverClass=com.mysql.cj.jdbc.DriverI hope I can help you see , Is learning JDBC, But the first step failed to connect .
Problems encountered later :
- ping no 3306
Start mysql after , The connection still failed .sudo /usr/local/mysql/support-files/mysql.server startStarting MySQLSUCCESS!
open Navicat And found out : Can't connect to local server through socket '/tmp/mysql.sock' (2)
wait . Is a series of problems , So I decided to uninstall today mysql.
Cannot delete... From the command line mysql after , I am directly in the system preferences Mysql Choose uninstall. Then on the official website https://downloads.mysql.com/archives/community/
Downloaded the computer version of dmg file , Direct installation . The choice is Strong password, The choice before was legacy password( It's the old way ). First download before mysql after , Try to Navicat On the establishment of mysql Connections often fail , Later, I checked the use set file and wrote the location of the host as “127.0.0.1”, The connection name is written as "localhost" To succeed .
Now uninstall and reinstall , actually JDBC Connect mysql succeed ! Thank you. !
边栏推荐
- The solution of invalid @data annotation in idea2018
- UBIFS FAQ and HOWTO
- Go language advantages and learning Roadmap
- Question bank and answers for 2022 melting welding and thermal cutting operation certificate examination
- Three ways of reflection
- Pyqt5:slider slider control
- 马志强:语音识别技术研究进展和应用落地分享丨RTC Dev Meetup
- Fuluo classic source code Fuluo classic system development principle sharing
- Arduino Uno接JQ8900-16p语音播报模块
- Multivalued mapping: arraylistmultimap and hashmultimap
猜你喜欢

Niuke: two numbers that only appear once in the array

ASLR

Configuring the command line compiled environment -msvc

Rs232/rs485 to 4G DTU uploading temperature and humidity sensor data based on Modbus protocol to remote TCP server

B_QuRT_User_Guide(16)

HUST Software Engineering (Experiment 2) -- TDD test driven development experiment.

Application of the remote acquisition IOT gateway of the Bashir trough flowmeter in open channel flow monitoring

The two request sessionids of the same user are inconsistent ----- record the problem

intXX_ T and int_ fastXX_ T what is the difference- What is the difference between intXX_ t and int_ fastXX_ t?

File compositor
随机推荐
微信模版消息errcode“:40165,“errmsg“:“invalid weapp pagepath
Construction of Flink development environment and wordcount
判断一串数字是否是快速排序某一次的结果
【长时间序列预测】Aotoformer 代码详解之[3]模型整体架构分析
Arduino uno connected to jq8900-16p voice broadcast module
数组全全排列
If you understand the logic of mining and carbon neutrality, you will understand the 100 billion market of driverless mining areas
Wechat template message errCode ": 40165," errmsg ":" invalid web pagepath
Error in Solr access: error initializing queryelevationcomponent
Hqchart nailing applet tutorial 1- create a K-line diagram
CPT 102_ LEC 15
最长递增子序列
How can Delma's own brand "take off" when Philips is listed on the market?
Arduino Uno接JQ8900-16p语音播报模块
【大咖秀】博睿数据眼中的AIOps,选择正确的赛道正确的人
CPT 102_ LEC 13-14
org. apache. solr. common. SolrException:Could not load core configuration for core hotel
三维GIS行业需求及展望
The two departments jointly issued the nine provisions on fire safety management of off campus training institutions
HQChart钉钉小程序教程1-创建K线图