DBCP,CP30,proxool连接池在spring hibernate中的配置

阅读更多
用spring默认的连接池性能效率不高,今天我为大家介绍三种流行的连接池配置:
1.连接池的jar文件通过查找类在网上能够找到。
2.我首先是数据库信息放置在jdbc.propertity文件中用spring加载这样方便
3.如想了解决整个项目请见::http://zz563143188.iteye.com/blog/1825168 

收集五年的开发资料下载地址:  http://pan.baidu.com/share/home?uk=4076915866&view=share
 
  
 
1.jdbc.propertity常用配置字符串
 
#Oracle?????
#ConUsePool true  use connection pool,false not use connection pool
ConUsePool= true
#DsName datasource name
#DsName=gtcs
#DbType:database type
 
#DbType=oracle---------------------------------------------------------------
#jdbc.driver=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:ora9i
#jdbc.username=gtcs
#jdbc.password=11
 
#SQL Server------------------------------------------------------------------
#jdbc.driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
#jdbc.url=jdbc:microsoft:sqlserver:// localhost:1433;DatabaseName=wpgl
#jdbc.username=sa
#jdbc.password=
 
#My SQL----------------------------------------------------------------------
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://127.0.0.1/ anydata?useUnicode=true&characterEncoding= utf-8
#jdbc.username=root
#jdbc.password=root
#select to_char(sysdate,'yyyy- mm-dd hh24:mi:ss') from dual
 
 
#jdbc.password=
 
#Aceess----------------------------------------------------------------------
jdbc.driver= sun.jdbc.odbc.JdbcOdbcDriver
#jdbc.url=jdbc:odbc:anydata
jdbc.url= jdbc\ :   odbc\:driver\={Microsoft   Access   Driver   (*.mdb)};DBQ\=E\:\\workspace\\anyData003.mdb
jdbc.username=
jdbc.password=
 
#proxool db
#proxool.driver=oracle.jdbc.driver.OracleDriver
#proxool.url=jdbc:oracle:thin:@192.168.1.16:1521:ETLDBS
#proxool.username=report
#proxool.password=report
#proxool.alias=dbpool
#proxool.prototypeCount=5
#proxool.maximumConnectionCount=100
#proxool.minimumConnectionCount=10
 
 
jdbc.initialSize= 1
jdbc.maxActive= 30
jdbc.maxIdle= 2
jdbc.minIdle= 1
jdbc.timeBetweenEvictionRunsMillis=   3600000
jdbc.minEvictableIdleTimeMillis= 3600000
 
#hibernate的配置信息
hibernate.show_sql= true
hibernate.dialect= org.hibernate.dialect.SQLServerDialect
hibernate.hbm2ddl.auto= update
hibernate.jdbc.fetch_size= 10
hibernate.default_batch_fetch_size=   10
hibernate.connection.pool_size= 1
hibernate.current_session_context_class=   thread
hibernate.format_sql= true
hibernate.cache.provider_class= net.sf.ehcache.hibernate.SingletonEhCacheProvider
hibernate.cache.use_second_level_cache=   true
hibernate.cache.use_query_cache= true
 
 
 
 
 
 
 
 
 
 
 
  
2.以下是spring配置 DBCP,CP30及proxool连接池
 
xml   version = "1.0"   encoding =   "UTF-8" ?>
< beans   xmlns = "http://www.springframework.org/schema/beans"
         xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"   xmlns:aop = "http://www.springframework.org/schema/aop"
         xmlns:dwr = "http://www.directwebremoting.org/schema/spring-dwr"
         xmlns:mvc = "http://www.springframework.org/schema/mvc"   xmlns:tx = "http://www.springframework.org/schema/tx"
         xmlns:context = "http://www.springframework.org/schema/context"
         xsi:schemaLocation = "http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.directwebremoting.org/schema/spring-dwr
            http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
         default-autowire = "byName"   >
        
 
 
 
        
         < bean   id =   "propertyConfigurer"
               class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"   >
               < property   name = "location"   >
                     < value >   classpath:jdbc.properties value   >
               property >
 
         bean >
 
        
        
 
        
 
         < bean   id =   "c3p0"   class   = "com.mchange.v2.c3p0.ComboPooledDataSource"
               destroy-method = "close"   >
               < property   name = "driverClass"   value = "${jdbc.driver}"   />
               < property   name = "jdbcUrl"   value = "${jdbc.url}"   />
               < property   name = "user"   value = "${jdbc.username}"   />
               < property   name = "password"   value = "${jdbc.password}"   />
              
               < property   name = "acquireIncrement"   value = "5"   />
              
               < property   name = "acquireRetryAttempts"   value = "30"   />
              
               < property   name = "acquireRetryDelay"   value = "1000"   />
              
               < property   name = "autoCommitOnClose"   value = "false"   />
              
               < property   name = "checkoutTimeout"   value = "10000"   />
              
               < property   name = "idleConnectionTestPeriod"   value = "60"   />
              
               < property   name = "initialPoolSize"   value = "10"   />
              
               < property   name = "minPoolSize"   value = "5"   />
              
               < property   name = "maxPoolSize"   value = "30"   />
              
               < property   name = "maxIdleTime"   value = "60"   />
              
               < property   name = "automaticTestTable"   value = "c3p0_TestTable"   />
              
               < property   name = "breakAfterAcquireFailure"   value = "false"   />
         bean >
 
        
 
         < bean   id =   "bonecp"   class   = "com.jolbox.bonecp.BoneCPDataSource"
               destroy-method = "close"   >
               < property   name = "driverClass"   value = "${jdbc.driver}"   />
               < property   name = "jdbcUrl"   value = "${jdbc.url}"   />
               < property   name = "username"   value = "${jdbc.username}"   />
               < property   name = "password"   value = "${jdbc.password}"   />
              
               < property   name = "idleConnectionTestPeriodInMinutes"   value = "60"   />
              
               < property   name = "idleMaxAgeInMinutes"   value = "30"   />
              
               < property   name = "maxConnectionsPerPartition"   value = "30"   />
              
               < property   name = "minConnectionsPerPartition"   value = "10"   />
              
               < property   name = "partitionCount"   value = "3"   />
              
               < property   name = "acquireIncrement"   value = "5"   />
              
               < property   name = "statementsCacheSize"   value = "100"   />
              
               < property   name = "releaseHelperThreads"   value = "3"   />
         bean >
 
        
         < bean   id =   "proxool"   class = "org.logicalcobwebs.proxool.ProxoolDataSource"   >
               < property   name = "driver"   value = "${jdbc.driver}"   />
               < property   name = "driverUrl"   value = "${jdbc.url}"   />
               < property   name = "user"   value = "${jdbc.username}"   />
               < property   name = "password"   value = "${jdbc.password}"   />
              
               < property   name = "alias"   value = "proxool_alias"   />
              
               < property   name = "prototypeCount"   value = "4"   />
              
               < property   name = "minimumConnectionCount"   value = "1"   />
              
               < property   name = "maximumConnectionCount"   value = "30"   />
              
               < property   name = "houseKeepingTestSql"   value = "select CURRENT_DATE"   />
         bean >
 
        
         < bean   id =   "dbcp"   class   = "org.apache.commons.dbcp.BasicDataSource"
               destroy-method = "close"   >
               < property   name = "driverClassName"   value = "${jdbc.driver}"   />
               < property   name = "url"   value = "${jdbc.url}"   />
               < property   name = "username"   value = "${jdbc.username}"   />
               < property   name = "password"   value = "${jdbc.password}"   />
              
               < property   name = "initialSize"   value = "1"   />
              
               < property   name = "maxActive"   value = "30"   />
              
               < property   name = "maxIdle"   value = "2"   />
              
               < property   name = "minIdle"   value = "1"   />
              
               < property   name = "timeBetweenEvictionRunsMillis"   value = "3600000"   />
              
               < property   name = "minEvictableIdleTimeMillis"   value = "3600000"   />
         bean >
 
beans >
 
3.上面就是几中常用的连接池配置,需要下载相应的jar或者了解使用方法。

 

你可能感兴趣的:(DBCP,CP30,proxool,spring,hibernate)