title: Is it necessary to close connection and statement when method terminates?
body: <p>In JDBC literatur I often encounter snippets like</p>
  
  <pre><code>void databaseCall() {
      Connection con = null;
      Statement statement = null        
      try {      
            con = getConnection(...);    
            statement = con.createStatement(...);        
            // do some query
      } catch (SQLException e) {
           // bla bla
      } finally {
           try {con.close();} catch (Exception e1) {}
           try {statement.close();} catch (Exception e1) {}
      }
  }
  </code></pre>
  
  <p>I know it's best practice to close connections and statements explicity, but, in this case,  apparently the resources <code>con</code> and <code>statement</code> will be closed when the method is finished, i.e., when the <code>try</code> block is finished. Is the <code>close</code> statements in the <code>finally</code> block really necessary? Even if we did not release the resources explicitly, wouldn't they be closed any way when the method is finished?</p>