spring中进行连接池使用c3p0进行配置,参考代码

<? xml version="1.0" encoding="UTF-8" ?>
<! DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd"
>
< beans >
    
< bean  id ="propertyConfigurer"  class ="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
        
< property  name ="location" >
            
< value > classpath:jdbc.properties </ value >
        
</ property >
    
</ bean >

    
< bean  id ="c3p0DataSource"  class ="com.mchange.v2.c3p0.ComboPooledDataSource"
          destroy-method
="close" >
        
< property  name ="driverClass" >
            
< value > ${db.driverClass} </ value >
        
</ property >
        
< property  name ="jdbcUrl" >
            
< value > ${db.url} </ value >
        
</ property >
        
< property  name ="properties" >
            
< props >
                
< prop  key ="c3p0.acquire_increment" > 5 </ prop >
                
< prop  key ="c3p0.idle_test_period" > 100 </ prop >
                
< prop  key ="c3p0.max_size" > 100 </ prop >
                
< prop  key ="c3p0.max_statements" > 0 </ prop >
                
< prop  key ="c3p0.min_size" > 10 </ prop >
                
< prop  key ="user" > ${db.user} </ prop >
                
< prop  key ="password" > ${db.pass} </ prop >
            
</ props >
        
</ property >
    
</ bean >

    
< bean  id ="sessionFactory"  class ="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
        
< property  name ="hibernateProperties" >
            
< props >
                
< prop  key ="hibernate.dialect" > ${hibernate.dialect} </ prop >
                
< prop  key ="hibernate.show_sql" > ${hibernate.show_sql} </ prop >
            
</ props >
        
</ property >
        
< property  name ="dataSource"  ref ="c3p0DataSource" />
        
< property  name ="annotatedClasses"  value ="martin.dwr.demo.model.User" />
    
</ bean >

    
< bean  id ="userDao"  class ="martin.dwr.demo.dao.hibernate.HibernateUserDAO" >
        
< property  name ="sessionFactory"  ref ="sessionFactory" />
    
</ bean >
</ beans > 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值