简体   繁体   English

在JPA中使用连接池

[英]Using Connection Pool in JPA

I hava a standalone JPA (Hibernate) - MySQL Application. 我有一个独立的JPA(Hibernate) - MySQL应用程序。

My persistence.xml looks like: 我的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>

I want to use a Connection Pool (say Apache DBCP) in this application, what changes do i need to make to persistence.xml? 我想在此应用程序中使用连接池(比如Apache DBCP),我需要对persistence.xml进行哪些更改?

You can use the c3p0 connection pooling for hibernate. 您可以使用c3p0连接池进行休眠。 Check this url C3P0 configuration 检查此URL C3P0配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM