title: Clean up repetitive setup and cleanup Java(JDBC) code
body: <p>I've too many methods that repeatedly do something like</p>
  
  <pre><code>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) {}
  }
  </code></pre>
  
  <p>This setup/teardown/cleanup of statements and resultsets is repetive and hides the interesting pieces of code.</p>
  
  <p>Is there any pattern or idiom for handling this(without introducing any external framework) ?</p>