【问题标题】:Using Connection Pool in JPA在 JPA 中使用连接池
【发布时间】:2013-04-26 07:15:17
【问题描述】:

我有一个独立的 JPA (Hibernate) - MySQL 应用程序。

我的 persistence.xml 看起来像:

     <persistence-unit name="JPAProj" transaction-type="RESOURCE_LOCAL">
            <!-- Persistence provider -->
            <provider>
                org.hibernate.ejb.HibernatePersistence
            </provider>
          ....
          <properties>
                    <property name='hibernate.show_sql' value='true'/>
                    <property name='hibernate.format_sql' value='true'/>
                    <property name='hibernate.dialect' value='org.hibernate.dialect.MySQL5InnoDBDialect'/>
                    <property name='hibernate.hbm2ddl.auto' value='update'/>

                    <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
                    <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/classicmodels"/>
                    <property name="javax.persistence.jdbc.user" value="someuser"/>
                    <property name="javax.persistence.jdbc.password" value=""/>
           </properties>
     </persistence-unit>

我想在此应用程序中使用连接池(例如 Apache DBCP),我需要对 persistence.xml 进行哪些更改?

【问题讨论】:

标签: java hibernate jpa connection-pooling persistence.xml


【解决方案1】:

您可以使用 c3p0 连接池进行休眠。检查此网址C3P0 configuration

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-09-25
  • 1970-01-01
  • 1970-01-01
  • 2011-04-26
  • 1970-01-01
  • 1970-01-01
  • 2023-04-07
  • 2013-06-27
相关资源
最近更新 更多