c3p0 连接池配置
2015-08-19 13:18
351 查看
C3P0 可使用properties 配置文件方式,将c3p0.properties放在classpath目录下,如果为WEB应用,放在WEB-INF\classes下
c3p0.properties
#
# This file is detritus from various testing attempts
# the values below may change, and often do not represent
# reasonable values for the parameters.
#
c3p0.jdbcUrl=jdbc:oracle:thin:@127.0.0.1:1521:chenchi
c3p0.driverClass=oracle.jdbc.driver.OracleDriver
c3p0.user=hbota2
c3p0.password=ty1234
c3p0.minPoolSize=3
c3p0.maxPoolSize=20
#c3p0.testConnectionOnCheckout=true
#c3p0.testConnectionOnCheckin=true
#c3p0.checkoutTimeout=2000
#c3p0.idleConnectionTestPeriod=5
#c3p0.maxConnectionAge=10
#c3p0.maxIdleTime=2
#c3p0.maxIdleTimeExcessConnections=1
#c3p0.propertyCycle=1
#c3p0.numHelperThreads=10
#c3p0.unreturnedConnectionTimeout=15
#c3p0.debugUnreturnedConnectionStackTraces=true
#c3p0.maxStatements=30
#c3p0.maxStatementsPerConnection=5
#c3p0.maxAdministrativeTaskTime=3
#c3p0.preferredTestQuery=SELECT 1
#c3p0.preferredTestQuery=SELECT a FROM emptyyukyuk WHERE a = 5
#c3p0.preferredTestQuery=SELECT a FROM testpbds WHERE a = 5
#c3p0.usesTraditionalReflectiveProxies=true
#c3p0.automaticTestTable=PoopyTestTable
#c3p0.acquireIncrement=4
#c3p0.acquireRetryDelay=1000
#c3p0.acquireRetryAttempts=60
#c3p0.connectionTesterClassName=com.mchange.v2.c3p0.test.AlwaysFailConnectionTester
#c3p0.initialPoolSize=10
com.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog
#com.mchange.v2.log.MLog=com.mchange.v2.log.jdk14logging.Jdk14MLog
#com.mchange.v2.log.MLog=com.mchange.v2.log.FallbackMLog
com.mchange.v2.log.NameTransformer=com.mchange.v2.log.PackageNames
com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=ALL
#com.mchange.v2.c3p0.VMID=poop
java
代码
ComboPooledDataSource cpds = new ComboPooledDataSource();
Connection conn = cpds.getConnection();
//
业务代码
conn.close();
c3p0.properties
#
# This file is detritus from various testing attempts
# the values below may change, and often do not represent
# reasonable values for the parameters.
#
c3p0.jdbcUrl=jdbc:oracle:thin:@127.0.0.1:1521:chenchi
c3p0.driverClass=oracle.jdbc.driver.OracleDriver
c3p0.user=hbota2
c3p0.password=ty1234
c3p0.minPoolSize=3
c3p0.maxPoolSize=20
#c3p0.testConnectionOnCheckout=true
#c3p0.testConnectionOnCheckin=true
#c3p0.checkoutTimeout=2000
#c3p0.idleConnectionTestPeriod=5
#c3p0.maxConnectionAge=10
#c3p0.maxIdleTime=2
#c3p0.maxIdleTimeExcessConnections=1
#c3p0.propertyCycle=1
#c3p0.numHelperThreads=10
#c3p0.unreturnedConnectionTimeout=15
#c3p0.debugUnreturnedConnectionStackTraces=true
#c3p0.maxStatements=30
#c3p0.maxStatementsPerConnection=5
#c3p0.maxAdministrativeTaskTime=3
#c3p0.preferredTestQuery=SELECT 1
#c3p0.preferredTestQuery=SELECT a FROM emptyyukyuk WHERE a = 5
#c3p0.preferredTestQuery=SELECT a FROM testpbds WHERE a = 5
#c3p0.usesTraditionalReflectiveProxies=true
#c3p0.automaticTestTable=PoopyTestTable
#c3p0.acquireIncrement=4
#c3p0.acquireRetryDelay=1000
#c3p0.acquireRetryAttempts=60
#c3p0.connectionTesterClassName=com.mchange.v2.c3p0.test.AlwaysFailConnectionTester
#c3p0.initialPoolSize=10
com.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog
#com.mchange.v2.log.MLog=com.mchange.v2.log.jdk14logging.Jdk14MLog
#com.mchange.v2.log.MLog=com.mchange.v2.log.FallbackMLog
com.mchange.v2.log.NameTransformer=com.mchange.v2.log.PackageNames
com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=ALL
#com.mchange.v2.c3p0.VMID=poop
java
代码
ComboPooledDataSource cpds = new ComboPooledDataSource();
Connection conn = cpds.getConnection();
//
业务代码
conn.close();
相关文章推荐
- linux 命令 - 切换目录cd
- 构造 HDOJ 5400 Arithmetic Sequence
- Saltstack系列:Saltstack分组
- 360:2015校招_俩个绝对路径找相对路径
- jdbc:oracle:thin:@192.168.3.98:1521:orcl(详解)
- Android应用程序基础(二)
- 【物理白痴进化论,欢迎吐槽】键盘按键原理及应用
- iOS TextField内容为空时设置按钮为不可用
- Windows下安装并设置Redis
- Hdu 5396 Expression (区间Dp)
- 6.7Pointers to Functions
- 使用JPA来执行本地SQL语句查询
- 2015上半年手机GPU排行榜
- WIN版的Jenkins Master加入LINUX的SLAVE节点,并作C++程序的集成交付
- HTTP 错误 404.17 - Not Found
- HDU 1312 Red and Black 【DPS】
- 一个初学者对于MVC架构的理解
- Android三种播放视频的方式
- [LeetCode] Ugly Number 丑陋数
- 远程读取XML根级别上的数据无效。 行 1,位置 1