Skip to main content

Connection Pool: cannot connect to or ping postgresql server

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
chw_1
Offline
Joined: 2012-08-07

Hi,

I have created a connection pool, but when pressing the Ping button in the Glassfish administration console I get the following error:

WARNING: RAR8054: Exception while creating an unpooled [test] connection for pool [ connectionPool ],
Connection could not be allocated because: Connection refused.
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

SEVERE: RestResponse.getResponse() gives FAILURE.
endpoint = 'http://localhost:4848/management/domain/resources/ping-connection-pool.json';
attrs = '{id=connectionPool}'

The database works fine. Using psql command line tool or a Netbeans Database Connection I can connect without any problems.

When I try to deploy the application from Netbeans, I get a similar error, so I guess it's a problem with the connection pool.

Some additional information about connection pool settings:

GENERAL
Resource Type: javax.sql.DataSource
Datasource Classname: org.postgresql.ds.PGSimpleDataSource

ADDITIONAL SETTINGS
Password: ***
User: ***
URL: jdbc:postgresql://db_server:5432/db_name

My Glassfish version is glassfish-3.1.2.2, I use it from Netbeans 7.2 on Ubuntu 12.04.

I tried already to increase the logging level, but I didn't get much more information. Maybe I enabled the wrong loggers, there are so many.

Under JVM settings I also enabled debug mode, but I don't really know how to use it.

Before, I used ngrep to watch my traffic on port 5432, when pinging, but I couldn't see any traffic.

Furthermore, I copied the driver jars to
~/.netbeans/7.2/config/GF3_1/domain1/lib
~/.netbeans/7.2/config/GF3_1/domain1/lib/ext

Could someone with more experience then I have assist me in debugging my connection issue?
Thanks in advance,
CHW

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sm157516
Offline
Joined: 2005-03-28

Could you try using the URL format like : "jdbc:postgresql://DB_HOSTNAME/DATABASE_NAME:5432" ?

chw_1
Offline
Joined: 2012-08-07

Hi,

I just got it working!
I restarted from scratch using this guide:
http://www.hildeberto.com/2010/02/creating-connection-pool-to-postgresql...
but used
Resource Type: javax.sql.DataSource
Datasource Classname: org.postgresql.ds.PGSimpleDataSource

I also think that I used a wrong driver version...

The lesson learned: sometimes it may be easier to restart then debugging for hours.

Thank you.