书单推荐:成为Java顶级程序员架构师 ,这20来本(高薪)必看点击获取
端口错误或者数据库服务器没有启动
提示的错误信息如下:
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(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:132)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:273)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1639)
at com.mysql.jdbc.Connection.<init>(Connection.java:393)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:262)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at test.JDBCTest.oracleTest(JDBCTest.java:25)
at test.JDBCTest.main(JDBCTest.java:12)
** END NESTED EXCEPTION **
解决方法:查看端口是否正确,数据库服务器是否启动。
转载请注明:谷谷点程序 » com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: