Using Connection Pool in JPA
Asked Answered
E

1

6

I hava a standalone JPA (Hibernate) - MySQL Application.

My persistence.xml looks like:

     <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?

Euphuism answered 26/4, 2013 at 7:15 Comment(2)
I assume you also have spring here?Pilgarlic
related question #3945309Linear
T
5

You can use the c3p0 connection pooling for hibernate. Check this url C3P0 configuration

Tungsten answered 26/4, 2013 at 7:34 Comment(1)
Configuring Apache DBCP Connection Pool here: mkyong.com/hibernate/…Euphuism

© 2022 - 2024 — McMap. All rights reserved.