title: ResultSet not closed when connection closed?
body: <p>I've been doing code review (mostly using tools like FindBugs) of one of our pet projects and FindBugs marked following code as erroneous (pseudocode):</p>
  
  <pre><code>Connection conn = dataSource.getConnection();
  
  try{
      PreparedStatement stmt = conn.prepareStatement();
      //initialize the statement
      stmt.execute();
      ResultSet rs =  stmt.getResultSet();
      //get data
  }finally{
      conn.close();
  }
  </code></pre>
  
  <p>The error was that this code might not release resources. I figured out that the ResultSet and Statement were not closed, so I closed them in finally:</p>
  
  <pre><code>finally{
      try{
          rs.close()
      }catch(SqlException se){
          //log it
      }
      try{
          stmt.close();
      }catch(SqlException se){
          //log it
      }
      conn.close();
  }
  </code></pre>
  
  <p>But I encountered the above pattern in many projects (from quite a few companies), and no one was closing ResultSets or Statements.</p>
  
  <p>Did you have troubles with ResultSets and Statements not being closed when the Connection is closed? </p>
  
  <p>I found only <a href="http://www.theserverside.com/discussions/thread.tss?thread_id=41036" rel="noreferrer">this</a> and it refers to Oracle having problems with closing ResultSets when closing Connections (we use Oracle db, hence my corrections). java.sql.api says nothing in Connection.close() javadoc.</p>