I've too many methods that repeatedly do something like
Statement stmt = null;
ResultSet rstmt = null;
try {
    stmt = conn.createStatement();
    rstmt = stmt.executeQuery(...);
    while (rstmt.next()) {
        //handle rows
    }
} catch (SQLException e) {
    //handle errors
} finally {
    try {rstmt.close();} catch (SQLException ex) {}
    try {stmt.close();} catch (SQLException ex) {}
}
This setup/teardown/cleanup of statements and resultsets is repetive and hides the interesting pieces of code.
Is there any pattern or idiom for handling this(without introducing any external framework) ?
 
     
     
     
     
    