Mar*_*ias 9 java tomcat apache-commons-dbcp
We are facing a problem that the number of connections made to the database explodes during restarts of Tomcat 7.
Our configurations are below, set on Tomcat's context.xml:
<Resource auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
initialSize="1"
maxActive="10"
maxAge="600000"
maxIdle="5"
maxOpenPreparedStatements="200"
maxWait="10000"
minEvictableIdleTimeMillis="60000"
minIdle="0"
name="jdbc/backoffice"
password="backoffice"
poolPreparedStatements="true"
rollbackOnReturn="true"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="6000000"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@127.0.0.1:1521:DATABASE"
username="backoffice"
validationQuery="SELECT SYSDATE FROM DUAL"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"
/>
Run Code Online (Sandbox Code Playgroud)
After a restart of Tomcat, the opened connections number gets close to 700. A redeploy of the war (rename to ".war_bk" e rename back to ".war") resolves the problem.
Why this is happening? What can we do differently?
maxConnLifetimeMillis -1 连接的最大生命周期(以毫秒为单位)。超过此时间后,连接将无法通过下一次激活、钝化或验证测试。值为零或更小意味着连接具有无限的生命周期。
和最大总计
maxTotal 8 可同时从该池分配的最大活动连接数,或负数表示无限制。
您可以更改validationQuery为更简单的查询
validationQuery="SELECT 1 FROM DUAL"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
126 次 |
| 最近记录: |