title: Store each row in a resultset as an object in an array
body: <p>Essentially my problem is that I am returning a resultset from a jdbc query and i want to store each row as an object in an array. when i try to loop through the resultset- it only saves on object in the array- i suppose this is obviously due to the fact that the while loop is within the for loop- i have tried re-jigging the loops a few times but with no joy.
  Would be great to find a less complex and convuluted way of getting the objects passed into the array. </p>
  
  <pre><code>    ResultSet rs = st.executeQuery(query);
      Check c = new Check();
      rs.last();
      int numberOfRows = rs.getRow(); 
      Check checkArray [] = new Check [numberOfRows]; 
      rs.beforeFirst();
  
      for (int i = 0; i &lt; checkArray.length; i++)
      {
       while (rs.next())
       {
      c.setAmount(rs.getBigDecimal("AMOUNT"));
      c.setCheckNumber(rs.getString("CHECKNUMBER"));
      c.setComments(rs.getString("COMMENTS"));
      c.setId(rs.getLong("SETID"));
      c.setMailTo(rs.getString("MAILTO"));
      c.setPayTo(rs.getString("PAYTO"));
      c.setProcessed(rs.getBoolean("PROCESSED"));
      checkArray[i]= c;
  }
  }
  </code></pre>