java 在 JPA 中使用连接池
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16230746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Connection Pool in JPA
提问by Jasper
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 做哪些更改?
采纳答案by Vasu
You can use the c3p0 connection pooling for hibernate. Check this url C3P0 configuration
您可以使用 c3p0 连接池进行休眠。检查这个 url C3P0 配置