druid,dbcp,c3p0 连接池的配置及应用

阅读更多

原文:http://blog.csdn.net/chenleixing/article/details/45165753/ (druid 在spring中的配置及监控)

          http://www.open-open.com/lib/view/open1430558786084.html (druid的内置监控及使用方法)

 

我再想买中的使用方法,因为我链接的mycat 集群环境的mysql

      

     

   

     

     

     

     

     

      

     

     

     

     

     

     

         

     

     

     

     

     

     

     

     

      

 

 

dbcp样例

< bean id = "dataSource" class = "org.apache.commons.dbcp.BasicDataSource" destroy-method = "close" >
   < property name = "driverClassName" value = "com.mysql.jdbc.Driver" />
   < property name = "url" value = "${jdbc.url}" />
   < property name = "username" value = "${jdbc.username}" />
   < property name = "password" value = "${jdbc.password}" />
  
 < property name = "initialSize" value = "3" />
 
 < property name = "maxActive" value = "15" />
  
   < property name = "validationQuery" value = "select 1" />
  
   < property name = "testOnBorrow" value = "false" />
  
   < property name = "testWhileIdle" value = "true" />
  
   < property name = "testOnReturn" value = "false" />
 
 < property name = "maxIdle" value = "5" />
 
 < property name = "minIdle" value = "3" />
  
   < property name = "maxWait" value = "90000" />
 
 < property name = "removeAbandonedTimeout" value = "120" />
  
 < property name = "removeAbandoned" value = "true" />
 
 < property name = "timeBetweenEvictionRunsMillis" value = "60000" />
 
 < property name = "minEvictableIdleTimeMillis" value = "60000" />
bean >

druid样例

< bean id = "dataSource" class = "com.alibaba.druid.pool.DruidDataSource" init-method = "init" destroy-method = "close" >
  
   < property name = "url" value = "${jdbc_url}" />
   < property name = "username" value = "${jdbc_user}" />
   < property name = "password" value = "${jdbc_password}" />
  
   < property name = "initialSize" value = "3" />
  
   < property name = "minIdle" value = "3" />
  
   < property name = "maxActive" value = "15" />
  
   < property name = "maxWait" value = "60000" />
  
   < property name = "timeBetweenEvictionRunsMillis" value = "60000" />
  
   < property name = "minEvictableIdleTimeMillis" value = "120000" />
  
   < property name = "validationQuery" value = "SELECT 1" />
  
   < property name = "testWhileIdle" value = "true" />
  
   < property name = "testOnBorrow" value = "false" />
  
   < property name = "testOnReturn" value = "false" />
  
   < property name = "poolPreparedStatements" value = "true" />
  
   < property name = "maxPoolPreparedStatementPerConnectionSize" value = "100" />
    
  
bean >

c3p0样例

< bean id = "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method = "close" >
  
   < property name = "driverClass" value = "${jdbc.driverClassName}" />
   < property name = "jdbcUrl" value = "${jdbc.url}" />
   < property name = "user" value = "${jdbc.username}" />
   < property name = "password" value = "${jdbc.password}" />
  
   < property name = "minPoolSize" value = "3" />
  
   < property name = "maxPoolSize" value = "15" />
  
   < property name = "initialPoolSize" value = "3" />
  
   < property name = "acquireIncrement" value = "3" />
  
   < property name = "maxIdleTime" value = "120" />
  
   < property name = "idleConnectionTestPeriod" value = "60" />
  
   < property name = "preferredTestQuery" value = "select 1" />
  
   < property name = "acquireRetryAttempts" value = "10" />
  
   < property name = "testConnectionOnCheckout" value = "false" />
  
   < property name = "numHelperThreads" value = "32" />
bean >

 

 

 

你可能感兴趣的:(druid,dbcp,c3p0)