Statement, PreparedStatement 和ResultSet 用完也要 close

解决方案 »

  1.   

    http://www-900.ibm.com/developerWorks/cn/wsdd/library/bestpractices/closing_and_releasing_jdbc_resources.shtml
      

  2.   

    在未用pool的情况下如果Connection被关闭了,属下的Statement, ResultSet都会被关闭的。 是不是因为出Exception而导致的?
    一定要在try {} finally {closeConnection()}在finally里面关闭比较安全.
      

  3.   

    不管用不用 pool, 建议将 close 放在 finally 中做, 否则出错就会引起 Connection 不能正确关闭或返回连接池.