问题遇到的现象和发生背景
配置JDBC环境,出现错误
问题相关代码,请勿粘贴截图
C:\Users\86176\.jdks\corretto-1.8.0_322\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\lib\idea_rt.jar=63730:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\charsets.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\access-bridge-64.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\cldrdata.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\dnsns.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\jaccess.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\jfxrt.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\localedata.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\nashorn.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\sunec.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\sunjce_provider.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\sunmscapi.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\sunpkcs11.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\ext\zipfs.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\jce.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\jfr.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\jfxswt.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\jsse.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\management-agent.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\resources.jar;C:\Users\86176\.jdks\corretto-1.8.0_322\jre\lib\rt.jar;D:\jdbc\out\production\jdbc_Demo;D:\jdbc\mysql-connector-java-8.0.24\mysql-connector-java-8.0.24.jar jdbc_1.jdbcDemo
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Exception in thread "main" com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The 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:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at jdbc_1.jdbcDemo.main(jdbcDemo.java:16)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
The 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:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89)
at com.mysql.cj.NativeSession.connect(NativeSession.java:144)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:953)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
... 6 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:607)
at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)
... 9 more
Process finished with exit code 1