为什么连接没有关闭?

Why are connections not getting closed?

我有一段代码,我使用结果集连接到数据库,然后在获得必要的值后在 finally 块中关闭连接。

但由于某种原因查询仍然运行并且连接池没有释放。 有人可以帮忙吗

try {
 rsU = dbAccess.query(FasoCommon.sqlUpdatable, params, true);
if (rsU.next()) {
            updatable = rsU.getString("UpdatableFields");
            logger.info("UpdatableFields:: "+updatable);

            }
        }
finally {
        close(rsU, null, null);

}

private void close(ResultSet rs, Statement stmt, Connection conn) {
    if (rs != null) {
        try {
            rs.close();
            rs=null;
            //logger().info("ResultSet Closed : " + rs);
        } catch (SQLException e) {
            //logger().error("The result set cannot be closed.", e);
        }
    }
    if (stmt != null) {
        try {
            stmt.close();
            stmt=null;
            //logger().info("Statement Closed : " + stmt);
        } catch (SQLException e) {
            //logger().error("The statement cannot be closed.", e);
        }
    }
    if (conn != null) {
        try {
            conn.close();
            conn=null;
            //logger().info("Data Source Connection Closed : " + conn);
        } catch (SQLException e) {

        }
    }
} 

在 finally 块中,Connection 对象作为 null 传递,甚至 Statement 对象也作为 null 传递。

finally {
        close(rsU, null, null);

}

检查它们并传递这些对象引用,如果您有权访问它们并且 非空引用,传递给该 close() 方法并检查。

有一个设置对象即使在关闭 connection.Fixing 后仍保持对连接的引用,该部分解决了问题。