Hibernate > 3.3 and c3p0
As c3p0 does not seem to be bundled with Hibernate anymore (as of versions > 3.3, I am using Hibernate 3.6.0), I'd like to know how to integrate c3p0 with Hibernate.
Obviously the old approach with
<property name="connection.prov开发者_运维知识库ider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
does not seem to work anymore, as the class C3P0ConnectionProvider is not provided by Hibernate anymore. Do I now have to build this on my own or is it safe to integrate the hibernate-c3p0-3.3.x.jar?
Note: I am using bare Hibernate, no Spring etc.
I use the following in hibernate.cfg.xml
:
<!-- c3p0 config http://www.hibernate.org/214.html -->
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">60</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">0</property>
<property name="hibernate.c3p0.acquireRetryAttempts">1</property>
<property name="hibernate.c3p0.acquireRetryDelay">250</property>
I use the latest hibernate (currently 3.6.0 GA) and I've included in the classpath c3p0-0.9.1.2.jar
(currently latest). Everything works as expected.
perhaps you need hibernate-c3po-3..jar
<!-- Hibernate c3p0 connection pool -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.6.3.Final</version>
</dependency>
精彩评论