【问题标题】:Try to use C3P0 with Hibernate尝试将 C3P0 与 Hibernate 一起使用
【发布时间】:2013-12-25 18:07:07
【问题描述】:

我正在使用 JPA,并且有一个带有以下配置的 persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd ">


    <persistence-unit name="odontonewPU">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="false" />
<!--            <property name="hibernate.hbm2ddl.auto" value="update" /> -->

            <!--   C3P0 configuration -->
            <property name="hibernate.connection.provider_class"
                value="org.hibernate.connection.C3P0ConnectionProvider" />

            <property name="hibernate.c3p0.max_size" value="100" />
            <property name="hibernate.c3p0.min_size" value="0" />
            <property name="hibernate.c3p0.acquire_increment" value="1" />
            <property name="hibernate.c3p0.idle_test_period" value="300" />
            <property name="hibernate.c3p0.max_statements" value="0" />
            <property name="hibernate.c3p0.timeout" value="100" />
        </properties>
    </persistence-unit>

</persistence>

问题是当我尝试初始化我的 tomcat 时出现以下错误:

691 [Thread-2] ERROR org.hibernate.connection.ConnectionProviderFactory - Could not instantiate connection provider
java.lang.ClassNotFoundException: org.hibernate.connection.C3P0ConnectionProvider

在我的 pom.xml(我使用 maven)中,我有以下依赖项:

<dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

【问题讨论】:

    标签: java hibernate maven jpa c3p0


    【解决方案1】:

    该类是hibernate-c3p0 的一部分。您将需要添加一个依赖项

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>4.2.7.Final</version>
    </dependency>
    

    whichever version you need

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-31
      • 2018-06-08
      • 2016-03-25
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多