Reprinted:
1. Problem Description
WebProgramIt was very fast at the beginning of Tomcat, but after a while it was found that the speed became very slow.
Check log output and find exceptions as follows:
Org. Apache. commons. DBCP. sqlnestedexception: cannot get a connection, pool exhausted, cause:
Java. util. nosuchelementexception: timeout waiting for idle object
At the same time, in the sqlserver event probe, it is found that each SQL statement is executed to generate an audit login event. After the statement is executed
Audit logout event. It indicates that each Tomcat Request re-opens a new connection.
2. Problem Solving
The Data Source Definition of Tomcat provides three parameters:
A. if it is set to true, Tomcat will automatically check for recovery and reuse, and there is no normally closed connection. (the default value is false)
<Parameter>
<Name> removeabandoned </Name>
<Value> true </value>
</Parameter>
B. Set the number of seconds for a connection to be considered as a dropped connection.
<Parameter>
<Name> removeabandonedtimeout </Name>
<Value> 60 </value>
</Parameter>
C. output the collected logs. You can print out the exceptions in detail to find that there is a leak.
<Parameter>
<Name> logabandoned </Name>
<Value> true </value>
</Parameter>