Tuesday, November 15, 2011

Exception java.net.ConnectException: Error opening socket to server

If you get below mentioned error

Exception in thread "main" com.ibm.db2.jcc.b.un: [jcc][t4][2043][11550][3.53.95] Exception java.net.ConnectException: Error opening socket to server hostname/10.10.5.5 on port 3,934 with message: Connection timed out. ERRORCODE=-4499, SQLSTATE=08001
        at com.ibm.db2.jcc.b.bd.a(bd.java:319)
        at com.ibm.db2.jcc.b.bd.a(bd.java:337)
        at com.ibm.db2.jcc.t4.xb.a(xb.java:378)
        at com.ibm.db2.jcc.t4.xb.(xb.java:76)
        at com.ibm.db2.jcc.t4.a.x(a.java:263)
        at com.ibm.db2.jcc.t4.b.a(b.java:1789)
        at com.ibm.db2.jcc.b.jb.a(jb.java:530)
        at com.ibm.db2.jcc.b.jb.(jb.java:486)
        at com.ibm.db2.jcc.t4.b.(b.java:310)
        at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:214)
        at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:224)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
Caused by: java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at com.ibm.db2.jcc.t4.y.run(y.java:34)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.ibm.db2.jcc.t4.xb.a(xb.java:372)
        ... 11 more


As the error suggest, The database server's port is not open to establish connection with your server or local machine hence it is throwing Socket error. Just verify this error by using Telnet command, If this is the case then contact your server administrator to open the port on the destination server.

I am not sure on this, possibly this could be the one reason for the above error.