Why do this
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
cs.close();
rs.close();
}
Instead of this
} catch (SQLException sqle) {
sqle.printStackTrace();
}
rs.close();
cs.close();
Because if an exception gets thrown no code after the try
block is executed unless the exception is caught. A finally
block is always executed no matter what happens inside your try
block.