Hibernate persistence.xml中jpa的C3p0连接池不工作?

Hibernate persistence.xml中jpa的C3p0连接池不工作?,hibernate,jpa,jetty,tomcat6,c3p0,Hibernate,Jpa,Jetty,Tomcat6,C3p0,在尝试按照我能找到的所有示例配置c3p0之后,我仍然得到JDBC超时。我正在使用JPA、Hibernate、Tomcat、MySQL[AWS RDS]。以下是persistence.xml中的代码片段: <property name="javax.persistence.jdbc.url" value="jdbc:mysql://url..." /> <property name="javax.persistence.jdbc.driver" value="com.mysql.

在尝试按照我能找到的所有示例配置c3p0之后,我仍然得到JDBC超时。我正在使用JPA、Hibernate、Tomcat、MySQL[AWS RDS]。以下是persistence.xml中的代码片段:

<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://url..." />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="connection.provider_class"  value="org.hibernate.connection.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.acquire_increment" value="4" />
<property name="hibernate.c3p0.idle_test_period" value="3000" /> 
<property name="hibernate.c3p0.max_size" value="100" />
<property name="hibernate.c3p0.max_statements" value="15" />
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.timeout" value="100" /> 

配置看起来不错。激活日志记录并确保C3P0以适当的设置启动

2010-10-16 11:58:31,271 INFO [main] o.h.c.ConnectionProviderFactory [ConnectionProviderFactory.java:173] Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider ... 2010-10-16 11:58:31271信息[main]o.h.c.ConnectionProviderFactory[ConnectionProviderFactory.java:173]初始化连接提供程序:org.hibernate.connection.C3P0ConnectionProvider ...
我在这个博客上找到了答案:

persistence.xml中的属性是错误的,应该从hibernate开始拼写:

<persistence 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_1_0.xsd"
  version="1.0">
    <persistence-unit name="mypersistenceunitname">
      <properties>
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="hibernate.hbm2ddl.auto" value="create-drop" />

        <!-- Important -->
        <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>
问候,,
Stéphane(为赏金感到抱歉)

日志记录被激活(事实上,我使用jetty,一个Web服务器,它记录所有的事情)。我得到了非常相同的持久性文件,c3po和c3po for hibernate都是我的类路径(web inf/classes,所有东西都是通过maven部署的)。但我没有关于c3po的日志信息。请帮我解释一下错误。我决定为那个问题悬赏@Pascal Thivent的回答没有帮助,我没有关于c3po的日志记录(也启用了loggin)。你能帮忙吗
<persistence 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_1_0.xsd"
  version="1.0">
    <persistence-unit name="mypersistenceunitname">
      <properties>
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="hibernate.hbm2ddl.auto" value="create-drop" />

        <!-- Important -->
        <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>
2011-08-15 08:58:33 com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10]
2011-08-15 08:58:33 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@f3a94e12 [     connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@6297f706     ....