日期:2014-05-17  浏览次数:20760 次

mysql中不关闭ResultSet会有影响吗?
mysql中不关闭ResultSet会有影响吗?

------解决方案--------------------
最好还是关一下,因为CONNCECTION.CLOSE()这个方法也许会发生异常,
如果能正常关闭连接的情况下,我认为不用关闭RESULTSET也行。
------解决方案--------------------
这里有个 帖子就是关于“是不是只要关connection就好了”

http://stackoverflow.com/questions/103938/resultset-not-closed-when-connection-closed

One problem with ONLY closing the connection and not the result set, is that if your connection management code is using connection pooling, the connection.close() would just put the connection back in the pool. Additionally, some database have a cursor resource on the server that will not be freed properly unless it is explicitly closed.

javadoc规范是提及了只要connection关闭,其连带资源也会被回收。
但是连接如果是池化管理的话,连接关闭仅仅只是将连接还回池中,而不会回收其所占资源。
还有有些数据库的游标资源也不会释放。