0

I am not able to establish connection to Compose for PostgreSQL DB service using eclipse. Getting below error while Testing the connection.

org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. 
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122) 
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65) 
    at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:116) 
    at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:30) 
    at org.postgresql.jdbc3.Jdbc3Connection.(Jdbc3Connection.java:24) 
    at org.postgresql.Driver.makeConnection(Driver.java:369) 
    at org.postgresql.Driver.connect(Driver.java:245) 
    at org.eclipse.datatools.enablement.internal.postgresql.PostgreSQLJDBCConnection.createConnection(PostgreSQLJDBCConnection.java:87) 
    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105) 
    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54) 
    at org.eclipse.datatools.enablement.internal.postgresql.PostgreSQLJDBCConnection.(PostgreSQLJDBCConnection.java:47) 
    at org.eclipse.datatools.enablement.internal.postgresql.PostgreSQLConnectionFactory.createConnection(PostgreSQLConnectionFactory.java:51) 
    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) 
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) 
Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) 
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)

I am able to connect to the DB through the application deployed in BlueMix.

zcoop98
  • 2,590
  • 1
  • 18
  • 31
Deepak Naik
  • 43
  • 1
  • 5

2 Answers2

0

How are you populating the connection credentials? The application will have access the VCAP_SERVICES when run on Bluemix, but unless you have specifically copied that environment variable to your Eclipse environment, that information will not be available to your application.

  • I am using CF cli command "cf env " to get the service details.below are the details i have entered in eclipse to connect. Driver: PostgreSQL JDBC Driver, Database: , URL: jdbc:postgresql://:/ username:, password: Do we need to add any other details inorder to connect. – Deepak Naik Oct 07 '16 at 09:57
0

The error indicates that the connection was refused. This most likely means that the host and port combination you've entered is incorrect. You'll want to ensure that you can connect to the host.

You can check that your local system can connect by doing nc -vz xxxxx.dblayer.com 10000 where xxxxx.dblayer.com is the full hostname provided to you within the variable and 10000 is the port, also provided.

It seems as though your syntax/configuration may not be correct as a connection being refused would indicate that it cannot connect however it's not clear from your post what hostname/port it's actually trying to connect to.

Tim Yocum
  • 26
  • 1