1 2 Previous Next 28 Replies Latest reply: Aug 9, 2011 4:07 PM by 809814 RSS

    ResultSet : How to know when cursor is after the last row in result set?

    809814
      I apologize, I do not know how to format the post. :S

      <div class="jive-message-body"><pre class="jive-pre">rs = . . .;
      <font color="navy"><b>while</b></font> (rs.next()) <font color="navy">{</font>
      System.out.print(rs.getString(1));
      if(!rs.isAfterLast())
      System.out.print(",");
      <font color="navy">}</font>

      </pre></div>
                     


      This will always print a comma after the last column

      I can use rs.isBeforeFirst() or rs.isAfterLast() I get a comma before first column or after last column respectively.

      Edited by: verwire01 on Aug 9, 2011 10:29 AM

      Edited by: verwire01 on Aug 9, 2011 11:11 AM

      Edited by: verwire01 on Aug 9, 2011 11:21 AM
        1 2 Previous Next