aspose file tools*
The moose likes Object Relational Mapping and the fly likes DBCP could not obtain an idle db connection, pool exhausted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "DBCP could not obtain an idle db connection, pool exhausted" Watch "DBCP could not obtain an idle db connection, pool exhausted" New topic
Author

DBCP could not obtain an idle db connection, pool exhausted

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi All,
I am using Hibernate.
I am getting this exception in the logs and sometime it does not connect to the database.
Is there any free tool or software I could use to debug unclosed connections.
From the code I cannot find any unclosed connection. All the conections are colsed in the finally block.
How can I debug this?
This is in my hibernate.cfg.xml


This is in the context.xml
<Context debug="5" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="jndi_ds_log" suffix=".txt" timestamp="true"/>
<Resource
name="jdbc/dsnFreelancerdb"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="db url"
username="user"
password="pass"
maxActive="100"
maxIdle="30"
maxWait="10000"
removeAbandoned="true" />
</Context>
Thanks
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
What Happens if you bump up the pool size.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks for the reply.

When I increase the pool size to 200 it works fine.
But this is only QA. Around 3 people testing at a time.
In production I dont know how many people will hit the site at the same time.

Thanks
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
I know you said you did already. However, I will suggest you check closely for connection leaks?
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Is there a tool to find the exact statement causing the problem.

I see this sometimes in the logs, but when I look at the code it has the closing portion in the finally block.


Is it a problem with the this code?


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You'll need something that closes the Hibernate session. I see a method which would close the session if you called it, but I don't see any code which actually calls that method.
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks for the reply.
I use it like this in the servlet or any other code


Also I changed the hibernate.cg.xml to this, cause I read in the documentation that hibernates connection pooling is rudimentary.

Does anyone have any idea what is the max size of hibernate.c3p0.max_size.

Thanks
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Looks like your code is closing the Hibernate session correctly.

If you are using hibernate 2, this has to be 0 <property name="hibernate.c3p0.min_size">0</property>
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks,

what about the max size?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DBCP could not obtain an idle db connection, pool exhausted