Unable to connect to "Compose for PostgreSQL" DB created in bluemix through eclipse - postgresql

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.

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.

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.

Related

Unable to connect to remote PostgresSQL server with JDBC driver

I'm trying to connect to a remote PostgreSQL database using JDBC, however the connection times out.
To be able to access the remote server I'm connected to a tunnel. There is no problem when I'm trying to connect from the same network with JDBC, only remotely.
I'm able to connect to the database both remotely and locally using other tools (e.g. pgAdmin, HeidiSQL, python sqlalchemy/psycopg2), but not with JDBC. I do not need to add other options for remote connection with the other tools, simply host:port and user/pass.
Searching for solutions I have tried the following without success:
add property "ssl" with value "true" to the driver connection
add property "sslfactory" with value "org.postgresql.ssl.NonValidatingFactory"
add property "loginTimeout" with value 20
set listen_addresses = '*' in postgresql.conf on remote server
add host all all 0.0.0.0/0 md5 to pg_hba.conf on remote server
Using driver version postgresql-42.2.14. I'm attempting to connect using SQuirreL and MATLAB.
As other tools have no issue connecting I'm guessing this is about tweaking the JDBC settings.
What am I missing here?
Edit:
Trying to ping the IP of the remote server (192.168.x.x.) I get:
Reply from 10.x.x.x: Destination net unreachable.
At the same time I'm able to connect to the database on the same server IP. Is this a clue to the problem?
Connection url:
jdbc:postgresql://192.168.x.x:5432/<dbname>
Results of Test-NetConnection
PS > Test-NetConnection 192.168.x.x
WARNING: Ping to 192.168.x.x failed with status:
DestinationNetworkUnreachable
PS > Test-NetConnection 192.168.x.x -port 5432
ComputerName : 192.168.x.x
RemoteAddress : 192.168.x.x
RemotePort : 5432
InterfaceAlias : Local Area Connection 3
SourceAddress : 192.168.x.x
TcpTestSucceeded : True
Running tracert 192.168.x.x
Tracing route to 192.168.x.x over a maximum of 30 hops
1 <1 ms <1 ms <1 ms 192.168.0.1
2 10.x.x.x reports: Destination net unreachable.
Trace complete.
Stacktrace (SQuirreL):
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(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 org.postgresql.core.PGStream.<init>(PGStream.java:81)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:93)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:217)
at org.postgresql.Driver.makeConnection(Driver.java:458)
at org.postgresql.Driver.connect(Driver.java:260)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:147)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:136)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.lambda$execute$0(OpenConnectionCommand.java:93)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
You are pinging IP address in the range of 192.168.x.x and getting reply from 10.x.x.x. Those are two different sub-nets.
As odd as it seems, it does not go well with your initial statement about being able to connect via other means. If network was issue then other tools would have failed as well. Not getting a reply for ping "Request time out" is expected result if there is blockage.
"Destination unreachable" means there is no proper route available to the IP you are trying to get to. With that issue, no other connections to that host should be reachable from your host.
Please confirm if all connections you attempted were from same client host. Also have you tried ODBC connector to see if that works? That allows System DSNs and you do not need to do much in attempt to connect.
Please make sure you do tests either from same hosts or two machines on same network to simplify things.
With "Destination unreachable" error your client should not be talking to server in anyway if same destination IP is used.

Connection to postgresql from jsp

I can't connected to postgres server by my jsp. I have an error:
root cause
java.net.SocketException: Permesso negato (connect failed)
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
I connect to postgres server with phpPgAdmin and with my drupal sites?
Why I can't connect with my jsp??
I have this error in this line
connection = DriverManager.getConnection("jdbc:postgresql://localhost/tpinet.it", "postgres","xxxx");
I have jdbc driver in the correct path and I have installed 4 drupal sites that use this database and they are online.
Why in the jsp i have this error?

connect spring boot app to mongodb

i'm trying to connect my spring boot app to a remote mongodb database.
When i run my app i got this error:
2017-05-25 15:22:57.829 INFO 4532 --- [*******:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server mongodb-server-address:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na]
at java.lang.Thread.run(Unknown Source) [na:1.7.0_79]
Caused by: java.net.ConnectException: Connection refused: connect
By default MongoDB only binds to the loopback interface which makes it only accessible from localhost. To change that you need to edit this line in mongod.conf file;
you can change it to allow LAN and local connections or you can remove or comment out that line bind_ip = 127.0.0.1 to allow all connections.
For more info : MongoDB – Allow remote access

JBoss EAP 6.1 not able to shutdown with command

I am not able to shutdown jboss server with the below command.
Command :
JBOSS_HOME/bin/jboss-cli.sh --connect controller=$SERVER_IP_ADDRESS:$SERVER_PORT command=:shutdown
Each time I was killing the server to restart which is not a good process to do. as we are moving to PROD environment we should use shutdown command to stop the server instead of killing
I am getting the below error. Please help.
Server Log :
jboss#devkopmdmh01.corp.ybusa.net::/usr/local/prod/jboss/jboss-eap-6.1/jboss-as/bin > ./shutdownMDM.sh
org.jboss.as.cli.CliInitializationException: Failed to connect to the controller
at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:280)
Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at 10.0.15.162:8080
at org.jboss.as.cli.impl.CommandContextImpl.tryConnection(CommandContextImpl.java:951)
... 8 more
Caused by: java.io.IOException: java.net.ConnectException: JBAS012144: Could not connect to remote://10.0.15.162:8080. The connection timed out
at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeForResult(AbstractModelControllerClient.java:129)
... 11 more
Caused by: java.net.ConnectException: JBAS012144: Could not connect to remote://10.0.15.162:8080. The connection timed out
at org.jboss.as.protocol.ProtocolConnectionUtils.connectSync(ProtocolConnectionUtils.java:131)
... 13 more
The JBoss CLI is attempting to connect to the native management endpoint for the running JBoss and send a shutdown command. It looks like it's trying to send to 10.0.15.162:8080 which is not the right port (most likely).
Take a look in your bin/jboss-cli.xml file which should contain the host and port to connect to. For example:
<default-controller>
<host>localhost</host>
<port>9999</port>
</default-controller>

Trying to run play application in console on heroku

I'm trying to start a play application in a console on heroku using this line of code:
new play.core.StaticApplication(new java.io.File("."))
Unfortunately it seems to be having a problem connecting to my database. I'm using postgres. Here's my configuration from application.conf
db.default.driver=org.postgresql.Driver
db.default.url=${?DATABASE_URL}
db.default.user=myusername
db.default.password=mypassword
My app is able to access the database through regular use. Here's the error i'm getting:
c.j.b.h.AbstractConnectionHook - Failed to obtain initial connection Sleeping for 0ms and trying again. Attempts left: 0. Exception: java.net.ConnectException: Connection refused.Message:Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Configuration error: Configuration error[Cannot connect to database [default]]