Question

  <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

            <property name="c3p0.max_size">100</property>
    <property name="c3p0.idleConnectionTestPeriod">300</property>
    <property name="c3p0.acquire_increment">1</property> 
    <property name="c3p0.idle_test_period">100</property> <!-- seconds --> 
    <property name="c3p0.max_statements">0</property> 
    <property name="c3p0.min_size">10</property> 
    <property name="c3p0.timeout">100</property> <!-- seconds --> 

This is the configuration in hibernate.cfg.xml. I am using hibernate 3.2.5 and c3p0 0.9. I don't know what i missed in this configuration. After few request, it show connection reached max pool size and waiting for free resources. If i use without connection pooling configuration in my local machine, it won't show any error message. Please help me to find out the missing part.

Was it helpful?

Solution

I a using the following configuration an it is working without problems in long-run tests: (My datasource is configured by spring, but you can see the properties for c3p0 anyway)

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> 
    <property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
    <property name="jdbcUrl" value="${database.url}" />
    <property name="user" value="${database.login}" />
    <property name="password" value="${database.password}" />
    <property name="minPoolSize" value="3" />
    <property name="maxPoolSize" value="100" />
    <property name="maxStatements" value="1100" />
    <property name="maxStatementsPerConnection" value="120" />      
    <property name="checkoutTimeout" value="5000" />
    <property name="idleConnectionTestPeriod" value="60" />
</bean>

However I would guess your problem is not the configuration. I assume that not all connections are returned to the pool and so the pool runs dry after some time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top