Closing dangling connections. All connections must have a close() in a finally block.resin.3.0.4
hibernate2
mysql4(具体忘了) 后台有很多上面的错误信息,仔细检查了程序,没有发现未关闭连接的地方。困惑中,谁能指点一下关闭连接:
try{
sess.flush()
sess.close();
sess = null;
}
catch(Exception e) { }
这是一个封装好的方法,使用完连接后都会调用来关闭,不知道错在什么地方。谢谢~!
hibernate2
mysql4(具体忘了) 后台有很多上面的错误信息,仔细检查了程序,没有发现未关闭连接的地方。困惑中,谁能指点一下关闭连接:
try{
sess.flush()
sess.close();
sess = null;
}
catch(Exception e) { }
这是一个封装好的方法,使用完连接后都会调用来关闭,不知道错在什么地方。谢谢~!
所有的链接必须在finally块中调用close();
这是他的文档中推荐的使用方法:Session sess = factory.openSession();
Transaction tx;
try {
tx = sess.beginTransaction();
//do some work
...
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}
奇怪的是,这个错误不是一直出现。同样的关闭方法,有的类里报错,有的又不报错,不知道为什么