gpt4 book ai didi

java jdbc嵌套异常

转载 作者:行者123 更新时间:2023-11-29 07:10:05 24 4
gpt4 key购买 nike

我已经在 eclipse 中创建了客户端-服务器 gui 日历应用程序,但它不起作用。我有一个奇怪的异常(exception)..有人可以帮我解决吗?作为服务器,我使用 mysql 和 eclipse 的 fat jar 插件来制作可运行的 jar 文件。

com.mysql.jdbc.CommunicationsException: Communications link failure dueto underlying exception:

开始嵌套异常

java.net.ConnectException
MESSAGE: Connection refused

堆栈跟踪:

java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:218)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at calendarapplication.gui.CalendarApplication.main(CalendarApplication.java:40)

结束嵌套异常

发送到服务器的最后一个数据包是 2 毫秒前。

at com.mysql.jdbc.Connection.createNewIO(Connection.java:2847)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at calendarapplication.gui.CalendarApplication.main(CalendarApplication.java:40)

Exception in thread "main" java.lang.NullPointerException
at calendarapplication.gui.CalendarApplication.main(CalendarApplication.java:63)

问候,

最佳答案

检查您的 JDBC 连接字符串以确保您的端口号正确。默认情况下,MySQL 运行在 3306 上。您可以使用 >netstat -b 命令验证它

关于java jdbc嵌套异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5147612/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com