过一段时间后,在bea\user_projects\domains\%domainname%\%servername%目录下,打开%servername%.log,查找,"A JDBC pool connection leak was detected",如果WebLogic已经监控到有连接池泄漏的话,就可以找到以下日志,并且很清楚的告诉我们在哪一个类的哪行代码创建了连接,但没有关闭(注意红色加粗字体):
2008-5-22 上午11时47分20秒 CST Warning JDBC A JDBC pool connection leak was detected. A connection leak occurs when a connection obtained from the pool was not closed explicitly by calling close() and then was disposed by the garbage collector and returned to the connection pool. The following stack trace at create shows where the leaked connection was created. Stack trace at connection create:
at weblogic.jdbc.wrapper.PoolConnection.init(PoolConnection.java:75)
at weblogic.jdbc.pool.Driver.allocateConnection(Driver.java:254)
at weblogic.jdbc.pool.Driver.connect(Driver.java:84)
at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)
at weblogic.jdbc.jts.Driver.connect(Driver.java:140)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at com.cp.fw.dao.BaseDAO.getConnection(BaseDAO.java:78)
at com.cp.fw.dao.dataset.DataSetOp.init(DataSetOp.java:78)
at com.cp.fw.dao.dataset.DataSetOp.<init>(DataSetOp.java:45)
at com.cp.ia.util.WorkFlowUtil.getNextWrokFlowId(WorkFlowUtil.java:93)
at
……
另外一种方法:
在WebLogic Console,展开 %DomainName% -> Servers -> %ServerName%,选到Logging – Server页,在页面最下方点击 "View server log",同样查找 "A JDBC pool connection leak was detected",也可以找到同样的日志。
WebLogic对于日志事件的说明:
Message ID
BEA-001074
Subsystem
JDBC
Message
A JDBC pool connection leak was detected. A
connection leak occurs when a connection obtained
from the pool was not closed explicitly by calling
close() and then was disposed by the garbage
collector and returned to the connection pool. The
following stack trace at create shows where the
leaked connection was created. Stack trace at
connection create:
Detail
A JDBC pool connection leak was detected. A
connection leak occurs when a connection obtained
from the pool was not closed explicitly by calling
close() and then was disposed by the garbage
collector and returned to the connection pool. A
stack trace is printed indicating where the leaked
connection was created.
Cause
A JDBC pool connection leak was detected. A
connection leak occurs when a connection obtained
from the pool was not closed explicitly by calling
close() and then was disposed by the garbage
collector and returned to the connection pool. A
stack trace is printed indicating where the leaked
connection was created.
Action
Close the connection appropriately.