How to properly clean up JDBC resources in Java?
- by user523086
What is considered best practices when cleaning up JDBC resources and why? I kept the example short, thus just the cleaning up of the ResultSet.
finally
{
if(rs != null)
try{ rs.close(); } catch(SQLException ignored) {}
}
versus
finally
{
try{ rs.close(); } catch(Exception ignored) {}
}
Personally I favour the second option since it is a bit shorter. Any input on this is much appreciated.