views:

324

answers:

2

I have a Tomcat and PostgreSQL installed on a server. I'm having a connection problem trying to connect from my servlet to PostgreSQL database using c3p0 pool.

I can reach DB if I'm running Tomcat locally on my laptop. Also I can connect from server to DB using psql (i.e. command line sql utility). But when I'm trying to deploy my servlet to server and establish a connection I'm getting the following error:

java.sql.SQLException: Connections could not be acquired from the underlying database!
    com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
...
    com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
        com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
        com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
        com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)

What should I check to locate a problem? It should be a trivial issue but may be due to 4 a.m. I'm missing something :) Thanks in advance!

PS: Connection from all network interfaces are allowed to database. PostgreSQL JDBC driver and c3p0 pool are distributed in WAR. Tomcat configuration is very default. JNDI is not used.

A: 

how can you solve this this problem? can you explain it?

Volkan
You need to check a few things:1) java.policy which tomcat is using (e.g. /etc/tomcat5.5/policy.d/02debian.policy)2) db server settings (e.g. /etc/postgresql/pg_hba.conf )3) try connecting without pool first as in my case c3p0 was hiding important information from me
Alexey Kalmykov
A: 

You need to check a few things:

  1. java.policy which tomcat is using (e.g. /etc/tomcat5.5/policy.d/02debian.policy)
  2. db server settings (e.g. /etc/postgresql/pg_hba.conf)
  3. try connecting without pool first as in my case c3p0 was hiding important information from me
Alexey Kalmykov