Not able to establish database connection in eclipse

3k views Asked by At

I want to make a new database connection (DB2) in eclipse for the purpose of using JPA. In JPA perspective, in Data Source Explorer view, when I try to create a new db connection, I receive the following logs when I try to ping the server.

org.eclipse.datatools.connectivity.exceptions.DBNotStartException: No start database command was issued. ErrorCode = -4499, SQLState = 08001.
    at org.eclipse.datatools.enablement.ibm.db2.internal.luw.JDBCLUWJDBCConnection.getConnectException(JDBCLUWJDBCConnection.java:74)
    at org.eclipse.datatools.connectivity.ui.PingJob.getTestConnectionException(PingJob.java:81)
    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:63)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: com.ibm.db2.jcc.am.ro: [jcc][t4][2043][11550][4.8.87] Exception java.net.ConnectException: Error opening socket to server example.example.com/51.37.93.117 on port 50,000 with message: Connection timed out: connect. ERRORCODE=-4499, SQLSTATE=08001
    at com.ibm.db2.jcc.am.gd.a(gd.java:319)
    at com.ibm.db2.jcc.am.gd.a(gd.java:337)
    at com.ibm.db2.jcc.t4.zb.a(zb.java:378)
    at com.ibm.db2.jcc.t4.zb.<init>(zb.java:76)
    at com.ibm.db2.jcc.t4.a.y(a.java:306)
    at com.ibm.db2.jcc.t4.b.a(b.java:1796)
    at com.ibm.db2.jcc.am.lb.a(lb.java:570)
    at com.ibm.db2.jcc.am.lb.<init>(lb.java:522)
    at com.ibm.db2.jcc.t4.b.<init>(b.java:306)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:214)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:456)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:328)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
    at org.eclipse.datatools.enablement.ibm.db2.internal.luw.JDBCLUWConnectionFactory.createConnection(JDBCLUWConnectionFactory.java:26)
    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
    ... 1 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.ibm.db2.jcc.t4.ab.run(ab.java:34)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.ibm.db2.jcc.t4.zb.a(zb.java:372)
    ... 18 more

And I am successfully able to connect to the database using DbVisualizer.

1

There are 1 answers

0
Hovig On

Error opening socket to server {machine} on :

  1. port 60,000 with message: Connection refused. ERRORCODE=-4499, SQLSTATE=08001

  2. port 50,000 with message: Connection timed out: connect. ERRORCODE=-4499, SQLSTATE=08001

In the first one, connection refusal can be either 50,000 (port) or 60,000 (TCP/IP).

In your case, the problem can be caused possibly because:

  1. There's another instance using the port (50,000 indicates not availability of db2)
  2. Or the port has an issue (firewall blockage, wrong port number,..)

Check the library that you're using import com.ibm.db2.jcc.*; and set the right port setPortNumber(port). Use Telnet 51.37.93.117 50000 in command line to check the availability of the port, if blank screen then the port is open else the port might be close/busy.

Use this link here to reference the steps you can take for db2 configuration in the Data Source Exploreron how to stop, set, update and start commands to re-connect to or to create a database.