c3p0链接池的配置

测试了一下,支持数据库宕掉之后重启,tomcat不用重新启动,连接池会恢复链接,这点比dbcp好,下载地址
[url]
http://sourceforge.net/projects/c3p0
[/url]
配置说明如下:
<bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass">
<value>${jdbc.driverClassName}</value>
</property>
<property name="jdbcUrl">
<value>${jdbc.url}</value>
</property>
<property name="user">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="initialPoolSize"><value>10</value></property>
<property name="minPoolSize"><value>5</value></property>
<property name="maxPoolSize"><value>30</value></property>
<property name="acquireIncrement"><value>5</value></property>
<property name="maxIdleTime"><value>10</value></property>
<property name="maxStatements"><value>0</value></property>
</bean>

以下几个参数是使用的基本配置参数:
initialPoolSize:
Number of Connections a pool will try to acquire upon startup. Should be between minPoolSize and maxPoolSize
连接池初始化时获取的链接数,介于minPoolSize和maxPoolSize之间

minPoolSize:
Minimum number of Connections a pool will maintain at any given time.
最小链接数

maxPoolSize:
Maximum number of Connections a pool will maintain at any given time.
最大连接数

acquireIncrement:
Determines how many connections at a time c3p0 will try to acquire when the pool is exhausted.
在当前连接数耗尽的时候,一次获取的新的连接数

maxIdleTime:
Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire.
最大空闲的时间,单位是秒,无用的链接再过时后会被回收
阅读更多
文章标签: JDBC Tomcat .net
个人分类: 框架
上一篇hibernate annotation 定义字段的默认值和显示hql的格式化问题
下一篇XP安装后,不是管理员权限,用户帐户打不开
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭