It's not a secret anymore!
The moose likes Tomcat and the fly likes Tomcat throwing Cannot open connection error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat throwing Cannot open connection error" Watch "Tomcat throwing Cannot open connection error" New topic

Tomcat throwing Cannot open connection error

Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 181


I have 2 applications deployed in tomcat, but only one application is running for the other application when I invoke it in the browser I am getting the below error:-

Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.jdbc.ConnectionManager.openConnection(
at org.hibernate.jdbc.ConnectionManager.getConnection(
at org.hibernate.jdbc.JDBCContext.connection(
at org.hibernate.transaction.JDBCTransaction.begin(
at org.hibernate.impl.SessionImpl.beginTransaction(
at org.hibernate.ejb.TransactionImpl.begin(
... 23 more
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(
at org.hibernate.jdbc.ConnectionManager.openConnection(
... 28 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(
... 31 more

I have not configured the JNDI resources in tomcat as we are directly using DataSource configured in spring. Both the applications uses the same DB. Please tell me know how come one application is working and the other throwing the above error. Whether we need to increase the connection pool size in both the applications? How we can go about it?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

I'm afraid that's not a Tomcat problem and we don't have enough information about your connection classes to be able to tell anything.

You can set up Spring to get its connection settings from JNDI, however. I do it often.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Tomcat throwing Cannot open connection error
It's not a secret anymore!