藤井树441 2022-03-22 15:29 采纳率: 93.8%
浏览 62
已结题

配置JDBC环境,但是报错,如何解决?(语言-java)

问题遇到的现象和发生背景

配置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
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答

2条回答 默认 最新

  • MysticalDream 2022-03-22 15:33
    关注

    mysql启动了吗?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月30日
  • 已采纳回答 3月22日
  • 创建了问题 3月22日

悬赏问题

  • ¥30 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目
  • ¥15 数电几道习题,写出作答过程,ai一律不采用
  • ¥15 利用pthon计算薄膜结构的光导纳
  • ¥15 海康hlss视频流怎么播放
  • ¥15 Paddleocr:out of memory error on GPU
  • ¥30 51单片机C语言数码管驱动单片机为AT89C52