怎么检查jdbc连接是否关闭

2025-04-17 22:51:49
推荐回答(1个)
回答1:

Connection的isClosed方法

isValid方法也可以,如果连接尚未关闭并且仍然有效,则返回 true

#----------------apache dbcp配置-----------------------
#
dbcp.initialSize=15
#
dbcp.maxIdle=10
#
dbcp.minIdle=1
#最大连接数量
dbcp.maxActive=1000
#是否在自动回收超时连接的时候打印连接的超时错误
dbcp.logAbandoned=true
#是否自动回收超时连接
dbcp.removeAbandoned=true
#超时时间(以秒数为单位)
dbcp.removeAbandonedTimeout=300
#
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