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

配置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日

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作