Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DBCP could not obtain an idle db connection, pool exhausted

 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Happens if you bump up the pool size.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you said you did already. However, I will suggest you check closely for connection leaks?
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

what about the max size?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic