Breaking News
Home / Java / Java Issues / JDBC – link failure CommunicationsException

JDBC – link failure CommunicationsException

Exception

Caused by: com.mysql.jdbc.exceptions.jdbc4.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.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)
     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     <!>

     sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
     at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
     at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
     at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
     at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
     … 14 more
Caused by: 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:432)
     at java.net.Socket.connect(Socket.java:478)
     at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
     … 30 more

Answer

In this scenario the Database seems to be down (has crashed) or not reachable (firewall blocking the port) or invalid configuration(check host/ port or the sock descriptor). Once the source of the problem as stated above is fixed, it may be necessary to restart your program, server or the database connection pool if applicable to reinitialize the connection. 

[pb_builder]

Check Also

Data truncation: Data too long for column – JDBC

Issue Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘columname‘ at row 1     …

Advertisment ad adsense adlogger