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
{
protected void closeAll(){
closeResultSet();
closeStatement();
closeConnection();
}
protected void closeConnection(){
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
/*Logger*/
}
connection = null;
}
}
protected void closeStatement() {
if (stmt != null) {
try {
ocstmt.close();
} catch (SQLException e) {
/*Logger*/
}
ocstmt = null;
}
}
protected void closeResultSet() {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
/*Logger*/
}
rs = null;
}
}