Java JDBC中的语句泄漏

Java JDBC中的语句泄漏,java,jdbc,Java,Jdbc,JDBC中的语句泄漏: pstmt = StatementLeakage : An open JDBC Statement is not closed on all paths. This can cause a transaction or Statement resources to remain active indefinitely, slowing or preventing access to the database by other requests.: for (objec

JDBC中的语句泄漏:

  pstmt =
StatementLeakage : An open JDBC Statement is not closed on all paths. This can cause a transaction or Statement resources to remain active indefinitely, slowing or preventing access to the database by other requests.: for (object created at line = TunnelDBHandler:139, type = java.sql.PreparedStatement), object used at prepareStatement() @ TunnelDBHandler:139 
                 dbManager
                    .getConnection()
                   .prepareStatement(
                      "update TUNNEL_STORE set IS_TUNNEL_OPEN=? where TUNNEL_ID=?");

添加一个
finally
块,并在所有的(s)、(s)和(s)上调用
close()
。作为一个非常粗略的例子

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
  // ...
  // get a statement for stmt
  // get a resultset from the stmt
  // ...
  while (rs.next()) {

  }
} catch (SQLException e) {
  e.printStackTrace();
} finally {
  if (rs != null) {
    try {
      rs.close();
    } catch (SQLException e) {
    }
  }
  if (stmt != null) {
    try {
      stmt.close();
    } catch (SQLException e) {
    }
  }
  if (conn != null) {
    try {
      conn.close();
    } catch (SQLException e) {
    }
  }
}

非常感谢兄弟们这里的实际问题是
pstmt
有一个您尚未关闭的先前值。