weblogic jdbc leak 奇怪的session.connection()报错

首先来看 session和connection的区别
引自hibernate in action 285页
If, in some special cases, you need even more control over the SQL that is executed,
or if you want to call a stored procedure using JDBC, Hibernate offers you a
way to get a JDBC connection. A call to session.connection() returns the currently
active JDBC Connection from the Session. It’s not your responsibility to close this
connection, just to execute whatever SQL statements you like and then continue
using the Session (and finally, close the Session). The same is true for transactions;
you must not commit or roll back this connection yourself (unless you completely
manage the connection for Hibernate, without a connection pool or
container datasource).
也就是说,session.connection() 可以不用主动去关闭,当session.close()的时候会主动关闭这个链接(应该是同一个)。
--------------------------华丽的分割线-奇怪的现象出现了:-------
weblogic中报错
<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.JTAConnection.init(Lweblogic/jdbc/jta/DataSource;ILweblogic/jdbc/wrapper/XAConnection;)V(JTAConnection.java:76)
at weblogic.jdbc.jta.DataSource.getConnection()Ljava/sql/Connection;(DataSource.java:463)
at weblogic.jdbc.jta.DataSource.connect(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;(DataSource.java:408)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection()Ljava/sql/Connection;(RmiDataSource.java:329)
at org.hibernate.connection.DatasourceConnectionProvider.getConnection()Ljava/sql/Connection;(DatasourceConnectionProvider.java:69)
at org.hibernate.jdbc.JDBCContext.userConnection()Ljava/sql/Connection;(JDBCContext.java:117)
at org.hibernate.impl.SessionImpl.connection()Ljava/sql/Connection;(SessionImpl.java:373)
at com.nantian.threeinone.dao.business.dao.SplitDao.deleteCflsByDjbh(Ljava/lang/String;)V(SplitDao.java:1174)


有一个连接泄露的原因是因为deleteCflsByDjbh(Ljava/lang/String;)V(SplitDao.java:1174) 方法引起的。。
去看一个下那个代码

session.connection().createStatement().execute(updateSql);

session已经再之后 close掉 ,并且事务也已经提交成功,可是session.connection() 没有关闭!
这个没有关闭的意思就是 根本没释放到 weblogic的连接池中

很奇怪。。。。。。。。


有没有人解决一下
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值