【问题标题】:Hibernate > 3.3 and c3p0休眠 > 3.3 和 c3p0
【发布时间】:2010-11-29 13:03:06
【问题描述】:

由于 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 等。

【问题讨论】:

    标签: hibernate connection-pooling c3p0


    【解决方案1】:

    我在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>
    

    我使用最新的hibernate(目前是3.6.0 GA),并且我已经包含在类路径c3p0-0.9.1.2.jar(目前是最新的)中。一切正常。

    【讨论】:

      【解决方案2】:

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

      <!-- Hibernate c3p0 connection pool -->
      <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-c3p0</artifactId>
          <version>3.6.3.Final</version>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-15
        相关资源
        最近更新 更多