The loop should be surrounded by a `try{ ... } finally { statement.close() }`.