title: How to correctly close resources?
body: <p>I have methods that all propagate exceptions and then I have handling on one place, however I realized something.</p>
  
  <p>Let's say I have method like this</p>
  
  <pre><code>public void foo() throws Exception e {
    Statement stmt = createStatement();
    doSomething(stmt);
    stmt.close();
  }
  </code></pre>
  
  <p>My issue is that if exception is thrown by doSometing() method the statement will not be closed, but I don't want to handle exception there. Is the right approach to have try and catch that only rethrows exception and finally to close statement?</p>