I have a try-catch-finally block that looks like so:
ResultSet rs;
PreparedStatement ps;
Connection conn;
try {
for (int i = 0; i < list.size(); i++) {
** execute SQL query **
}
} catch (Exception e) {
throw e;
} finally {
** close result set **
** close prepared statement **
** close connection **
}
I've verified that my ArrayList list had 534 elements in it. The problem is that the finally block to close everything is executing after the first occurrence of my for loop which causes the next occurrence to throw an exception because the connection is now closed.
I've never encountered a situation where the finally block executes before the try block has completed. What could cause this scenario?