开发者

java jdbc nested exception

开发者 https://www.devze.com 2023-02-14 04:01 出处:网络
I have created client-server gui calendar application in eclipse but it doesn\'t work. I have such a strange exception.. Can someone help me to solve it. As a server I used mysql and fat jar plugin fo

I have created client-server gui calendar application in eclipse but it doesn't work. I have such a strange exception.. Can someone help me to solve it. As a server I used mysql and fat jar plugin for eclipse to make runnable jar file.

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

BEGIN NESTED EXCEPTION

java.net.ConnectException
MESSAGE: Connection refused

STACKTRACE:

java.net.ConnectEx开发者_JAVA百科ception: 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)

END NESTED EXCEPTION

Last packet sent to the server was 2 ms ago.

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)

Regards,


Check your JDBC connection string to make sure you have correct port number. By default MySQL runs on 3306. You can verify it by using >netstat -b command


Looks like your server (mysql) is not started at specified address and port.

0

精彩评论

暂无评论...
验证码 换一张
取 消