1

由于 c3p0 似乎不再与 Hibernate 捆绑在一起(从版本 > 3.3 开始,我使用的是 Hibernate 3.6.0),我想知道如何将 c3p0 与 Hibernate 集成。

显然是旧的方法

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

似乎不再起作用,因为 Hibernate 不再提供 C3P0ConnectionProvider 类。我现在必须自己构建它还是集成 hibernate-c3p0-3.3.x.jar 是否安全?

注意:我使用的是裸 Hibernate,没有 Spring 等。

4

2 回答 2

2

我在中使用以下内容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>

我使用最新的休眠(当前为 3.6.0 GA),并且已包含在类路径中c3p0-0.9.1.2.jar(当前为最新)。一切都按预期工作。

于 2010-11-29T16:23:05.630 回答
0

也许你需要hibernate-c3po-3..jar

<!-- Hibernate c3p0 connection pool -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>3.6.3.Final</version>
</dependency>
于 2012-03-25T09:48:35.783 回答