itVincent Blog - Java Working Fun!

技术引领时代!
posts - 117, comments - 181, trackbacks - 0, articles - 12

[原创]使用c3p0作为jpa的数据源

Posted on 2007-10-09 17:54 itVincent 阅读(2012) 评论(3)  编辑  收藏

使用c3p0作为jpa的数据源。标准jpa方式:编写persistence.xml写法如下:

<?xml version="1.0" encoding="UTF-8"?>
<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="jpaPU" transaction-type="RESOURCE_LOCAL">
        
<provider>org.hibernate.ejb.HibernatePersistence</provider>
        
<properties>
            
<property name="hibernate.connection.provider_class"
                value
="org.hibernate.connection.C3P0ConnectionProvider"/>
            
<property name="hibernate.connection.driver_class"
                value
="com.mysql.jdbc.Driver" />
            
<property name="hibernate.connection.url"
                value
="jdbc:mysql://192.168.101.50:3306/TEST" />
            
<property name="hibernate.connection.username"
                value
="user" />
            
<property name="hibernate.connection.password"
                value
="pwd" />
            
<property name="hibernate.show_sql" value="true" />
            
<property name="hibernate.hbm2ddl.auto" value="update" />
        
</properties>
    
</persistence-unit>

</persistence>

Feedback

# re: [原创]使用c3p0作为jpa的数据源  回复  更多评论   

2007-10-09 18:54 by 快乐的猪猪
不错

# re: [原创]使用c3p0作为jpa的数据源  回复  更多评论   

2008-01-02 15:29 by Meimei
睇唔明啊,麻烦解释下```
以嫁系08年啦,得闲写D野上去啦

# re: [原创]使用c3p0作为jpa的数据源  回复  更多评论   

2015-05-08 09:13 by ri
<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider"/>

只有注册用户登录后才能发表评论。


网站导航: