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

HowTo configure the C3P0 properties in hibernateconfig.xml

 
Ekta Matani
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using hibernate with mysql as database.
After few save & update operations, i am getting the following error :

[BasicResourcePool] com.mchange.v2.resourcepool.BasicResourcePool$Ac
- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).

how to resolve this?

the properties which i have configured in hibernateconfig.xml are set with following values:

<property name="c3p0.max_size">100</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">10</property> <!-- seconds -->
<property name="c3p0.acquireRetryAttempts">30</property>
<property name="c3p0.acquireIncrement">5</property>
<property name="c3p0.idleConnectionTestPeriod">300</property>
<property name="c3p0.initialPoolSize">20</property>
<property name="c3p0.maxPoolSize">100</property>
<property name="c3p0.maxIdleTime">300</property>
<property name="c3p0.maxStatements">50</property>
<property name="c3p0.minPoolSize">10</property>

do i need to add any other property tags?or any value changes required for properties?
Please help me.

Thank you,
Ekta
 
P.Sivaraj
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is this. Check the option to clear the connections.

Siva.
 
Emanuel Kadziela
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error basically means that the system (or more precisely the c3p0 connection pool manager) was asked for another(more) connection(s) by the application, but had all currently held connections checked out (being used) and tried to acquire 5 more connections from the database. It attempted to do this 30 times unsuccessfully, and gave up returning that error message. There are several things you should look at here. First, the simplest (dirty) solution would be to lower your aqcuireIncrement setting to 1, so the pool can ask the database for one new connection at a time, instead of 5. You can also bump up the acquireRetryAttempts to give it more chances to succeed. But, you should really look into the implications of this error message (why does it need to increment the pool, why does it fail to do so, etc.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic