Java 关闭的结果集,不带关闭语句

Java 关闭的结果集,不带关闭语句,java,mysql,sql,jdbc,Java,Mysql,Sql,Jdbc,在我的应用程序中,以下代码 ResultSet images = statement.executeQuery("SELECT id, filename, run" + " FROM images" + " JOIN comparer_results results ON results.toImageId = images.id" + " WHERE result <= 100"); while (images.next())

在我的应用程序中,以下代码

ResultSet images = statement.executeQuery("SELECT id, filename, run" +
          " FROM images" +
          " JOIN comparer_results results ON results.toImageId = images.id" +
          " WHERE result <= 100");

while (images.next()) {
    statement.executeUpdate("DELETE FROM images WHERE id = "
        + images.getInt("id"));

    File imageFile = new File(config.getProperty("system.imageDirectory")
        + File.separator
        + images.getString("filename") + ".jpg");
}
imageFile
实例化的行中。据我所知,这是由
images.getString(“filename”)
操作引起的。但是为什么结果集关闭了呢?我从来没有调用过这样的方法,结果集(
images.getInt(“id”)
)上的第一个操作运行得很好

statement.executeUpdate("DELETE FROM images WHERE id = "
    + images.getInt("id"));
您重新使用了
语句
。这意味着任何先前创建的
ResultSet
都将自动关闭

在这种情况下,必须使用两个
语句

statement.executeUpdate("DELETE FROM images WHERE id = "
    + images.getInt("id"));