isValid方法也可以,如果连接尚未关闭并且仍然有效,则返回 true
解决方案 »
- 金融软件开发和对日外包,哪个发展前景更好?
- Java九大隐性函数各自的作用 以及用法?
- 芝麻开门
- weblogic 10 r3里 想把jdk6的编译成jdk5的 用的是ejb3.0 这样可以用吗?
- 怎么对一个新闻的内容进行分页?
- 求助:关于LIST 和 HIBERNATE里的TRANSACTION
- Spring Initial Problem
- 在weblogic7里面使用smartupload组件上传文件的问题,java.lang.OutOfMemoryError
- struts高手请教了
- “锁表”是怎么一回事
- java动态加载jar中的类 报java.lang.NoClassDefFoundError错误
- 用iframe对页面分块,每个里面嵌一个jsp页面,jsp页面显示时占不满页面。在IE11不可以。
Io 异常: Software caused connection abort: socket write error
楼上你的那个方法isclosed我用了,都是false 没有发现连接关闭
#<!-- 初始化连接 -->
dbcp.initialSize=15
#<!-- 最大空闲连接 -->
dbcp.maxIdle=10
#<!-- 最小空闲连接 -->
dbcp.minIdle=1
#最大连接数量
dbcp.maxActive=1000
#是否在自动回收超时连接的时候打印连接的超时错误
dbcp.logAbandoned=true
#是否自动回收超时连接
dbcp.removeAbandoned=true
#超时时间(以秒数为单位)
dbcp.removeAbandonedTimeout=300
#<!-- 超时等待时间以毫秒为单位 6000毫秒/1000等于60秒 -->
dbcp.maxWait=3000
dbcp.testOnReturn=false
#set to 'SELECT 1'
dbcp.validationQuery = "SELECT * from c3p0testtable"
#set to 'true'
dbcp.testWhileIdle = true
#some positive integer
dbcp.timeBetweenEvictionRunsMillis = 3000000
#set to something smaller than 'wait_timeout'
dbcp.minEvictableIdleTimeMillis = 3200000
#if you don't mind a hit for every getConnection(), set to "true"
dbcp.testOnBorrow = true
#access date config ss
date=60000
我这样设置批量没有问题
配置:
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${database.driverClass}" />
<property name="jdbcUrl" value="${database.jdbcUrl}" />
<property name="user" value="${database.user}" />
<property name="password" value="${database.password}" />
<!--连接池中保留的最小连接数。-->
<property name="minPoolSize">
<value>10</value>
</property>
<!--连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize">
<value>100</value>
</property>
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize">
<value>20</value>
</property>
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime">
<value>60</value>
</property>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement">
<value>10</value>
</property>
</bean>
配置:
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${database.driverClass}" />
<property name="jdbcUrl" value="${database.jdbcUrl}" />
<property name="user" value="${database.user}" />
<property name="password" value="${database.password}" />
<!--连接池中保留的最小连接数。-->
<property name="minPoolSize">
<value>10</value>
</property>
<!--连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize">
<value>100</value>
</property>
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize">
<value>20</value>
</property>
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime">
<value>60</value>
</property>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement">
<value>10</value>
</property>
</bean>
dbcp.validationQuery = "SELECT * from c3p0testtable"
#set to 'true'
dbcp.testWhileIdle = true
#some positive integer
dbcp.timeBetweenEvictionRunsMillis = 3000000
#set to something smaller than 'wait_timeout'
dbcp.minEvictableIdleTimeMillis = 3200000
#if you don't mind a hit for every getConnection(), set to "true"
dbcp.testOnBorrow = true
设置一下这些 当连接中断后 自动创建连接
select count(*) from v$process