SilverStray
Programmer
Hi,
I'm just curious, and I am hoping to find an explanation. Why is it that if I execute a query, and when I close the Resultset inside catch statement, it does not throw the SQLException to the calling method?
My code is as follows:
ResultSet rs = null;
try {
rs = ps.executeQuery();
while (rs.next()) {
count = rs.getInt("CNT");
}
}
catch (SQLException e) {
//rs.close();
ps.close();
conn.close();
throw e;
}
If I uncomment the rs.close(), the SQLException is not passed to the calling method, but if I remove it, everything is ok. Will I not encounter a ResultSet Exception for unclosed Resultsets in the future?
I'm just curious, and I am hoping to find an explanation. Why is it that if I execute a query, and when I close the Resultset inside catch statement, it does not throw the SQLException to the calling method?
My code is as follows:
ResultSet rs = null;
try {
rs = ps.executeQuery();
while (rs.next()) {
count = rs.getInt("CNT");
}
}
catch (SQLException e) {
//rs.close();
ps.close();
conn.close();
throw e;
}
If I uncomment the rs.close(), the SQLException is not passed to the calling method, but if I remove it, everything is ok. Will I not encounter a ResultSet Exception for unclosed Resultsets in the future?