title: JDBC-ResultSet is closed in while-Loop
body: <p>I'm having a really bad time with a ResultSet, which is closed within a while-Loop for iterating this ResultSet. I have know the exact line in which the ResultSet is closed, but i have no idea why. </p>
  
  <pre><code>    public LinkedList&lt;Athlet&gt; alleAbrufen () throws SQLException {
          LinkedList&lt;Athlet&gt; alleAthleten = new LinkedList&lt;Athlet&gt;();
          String abrufenAthleten = "SELECT * FROM Athlet ORDER BY athlet_id";
          ResultSet athleten_rs = stmt.executeQuery(abrufenAthleten);
          while (athleten_rs.next()) {
              long id = athleten_rs.getInt(1);
              String name = athleten_rs.getString(2);
              LinkedList&lt;Leistung&gt; alleLeistungen = alleAbrufen((int) (id)); //after this line the ResultSet gets closed
              alleAthleten.add(new Athlet(id, name, alleLeistungen));
          }
          return alleAthleten;
      }
  
      public LinkedList&lt;Leistung&gt; alleAbrufen(int athlet_id) throws SQLException {
          LinkedList&lt;Leistung&gt; alleLeistungen = new LinkedList&lt;Leistung&gt;();
          String selectLeistungen = "SELECT * FROM Leistung WHERE athlet_id="+athlet_id;
          ResultSet rs = stmt.executeQuery(selectLeistungen);
          while (rs.next()) {
              long id = rs.getInt(1); 
              String bezeichnung = rs.getString(2);
              String datum = rs.getString(3);
              double geschwindigkeit = rs.getDouble(4);
              boolean selectedForSlopeFaktor = rs.getBoolean(5);
              int strecke_id = rs.getInt(7);
              long longAthlet_id = (long) athlet_id;
              Leistung leistung = new Leistung(strecke_id, longAthlet_id, bezeichnung, datum, geschwindigkeit);
              leistung.setLeistungID(id);
              leistung.setIsUsedForSlopeFaktor(selectedForSlopeFaktor);
              alleLeistungen.add(leistung);
          }
          return alleLeistungen;
      }
  </code></pre>
  
  <p>I marked the line after which the <code>ResultSet</code> is closed with a comment. <code>Alle</code> other methods, constructors, etc used in the above example are tested an working properly. Does anyone have a clue why calling the second method closes the <code>ResultSet</code> in the first method?</p>