藤井树441 2022-03-22 07:29 采纳率: 88.2%
浏览 67
已结题

配置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 07:33
    关注

    mysql启动了吗?

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

报告相同问题?

问题事件

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

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部