I'm having trouble configuring C3P0 as a datasource. I am configuring it as a separate data source bean and passing that into my session factory. The problem I'm having is that the instance of the ComboPooledDataSource is not picking up the properties I'm setting. Here's how I have the C3P0 connection pool configured and my session factory:
What I'm observing in the logs is when the ComboPooledDataSource gets initialized it only starts up with 3 connections in it's pool, instead of 10 as I'd configured it, and when it increments the number of connections it increments by 3, instead of by 5.Code:<bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.driver.classname}"/> <property name="jdbcUrl" value="${jdbc.url}"/> <!-- <property name="user" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> --> <property name="properties"> <props> <prop key="c3p0.acquire_increment">5</prop> <prop key="c3p0.idle_test_period">100</prop> <prop key="c3p0.max_size">100</prop> <prop key="c3p0.max_statements">0</prop> <prop key="c3p0.min_size">10</prop> <prop key="user">${jdbc.username}</prop> <prop key="password">${jdbc.password}</prop> </props> </property> </bean> <!-- property variables are pulled from hibernate.properties --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="c3p0DataSource"/> <property name="mappingResources"> <list> <!-- mapping files taken out for brevity --> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <!-- provides jmx statistics --> <prop key="hibernate.generate_statistics">true</prop> </props> </property> <property name="eventListeners"> <map> <entry key="merge"> <!-- allow hibernate's merge() method to update ID of the object, in case the object was transient (and hence there was no ID) The cost is that the merge() call now must incur a database call (to generate the ID in database) --> <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/> </entry> </map> </property> </bean>
Here's the debug statement which I think is telling me about the ComboPooledDataSource:
Code:trace com.mchange.v2.resourcepool.BasicResourcePool@8a129d [managed: 3, unused: 3, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@4ec1eb
Could someone tell me what I'm doing wrong?
Thanks,
Christian


Reply With Quote