为了账号安全,请及时绑定邮箱和手机立即绑定

数据库报错,如何解决?

请问我在DBHelper类里面运行了main方法测试,但是报错如下,怎么解决呢?

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 


** BEGIN NESTED EXCEPTION ** 


java.net.ConnectException

MESSAGE: Connection refused: connect


STACKTRACE:


java.net.ConnectException: Connection refused: connect

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:173)

at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:267)

at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739)

at com.mysql.jdbc.Connection.<init>(Connection.java:1553)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)

at java.sql.DriverManager.getConnection(DriverManager.java:582)

at java.sql.DriverManager.getConnection(DriverManager.java:185)

at util.DBHelper.getConnection(DBHelper.java:34)

at util.DBHelper.main(DBHelper.java:44)



** END NESTED EXCEPTION **




Last packet sent to the server was 18 ms ago.

at com.mysql.jdbc.Connection.createNewIO(Connection.java:2814)

at com.mysql.jdbc.Connection.<init>(Connection.java:1553)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)

at java.sql.DriverManager.getConnection(DriverManager.java:582)

at java.sql.DriverManager.getConnection(DriverManager.java:185)

at util.DBHelper.getConnection(DBHelper.java:34)

at util.DBHelper.main(DBHelper.java:44)


正在回答

1 回答

没有开启服务吧,资源管理器中---服务----服务--mysql,开启mysql服务

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

数据库报错,如何解决?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信