简体   繁体   中英

Tomcat jdbc connection pool, does not release connections after using

What may be reason for tomcat does not release connections after using?

Herem is my config

<Resource name="jdbc/DataSource" auth="Container"
type="javax.sql.DataSource" username="))" password="))"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="))"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
initialSize="55"
maxActive="55" maxIdle="55" maxWait="15000"

testWhileIdle="true"
testOnBorrow="true"
testOnReturn="false"
validationQuery="SELECT 1 FROM DUAL"
validationInterval="20000"

timeBetweenEvictionRunsMillis="30000"
removeAbandoned="true"
removeAbandonedTimeout="60"
/>

You still need to call connection.close() in your code to have the connection released to the pool. It does not happen automatically.

You can configure the pool to detect "left over connections" wiht:

removeAbandoned="true"
removeAbandonedTimeout="60"

connection inactive for longer than given number of seconds will be closed automatically and recycled by the pool

The most probable is that you don't close connections after using them. It can happens for example if you don't manage correctly exceptions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM