Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

must determine ResultSet.hasNext() without advancing the cursor

Status
Not open for further replies.

carpeliam

Programmer
Mar 17, 2000
990
US
Quick minds will say "hey, there's no ResultSet.hasNext(), only ResultSet.next()". Thing is, the "next()" method both advances the cursor and tests whether or not there is a next row. How can I determine whether there is a next row without advancing the cursor? Or I'll settle for determining whether there are ANY rows whatsoever.

(My first guess would be to say ResultSet.isAfterLast(), but that returns false if there are no rows in the result set.)

Thanks for any help. Liam Morley
lmorley@wpi.edu
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
 
after spending a lot of time on this, I came up with the following:<br><br><FONT FACE=monospace>(!rs.isLast() && ((rs.getRow() != 0) &#124;&#124; rs.isBeforeFirst()))</font><br><br>it takes advantage of the fact that rs.isBeforeFirst() returns true only if there are results in the result set; it will return false if there is an empty result set (as will rs.isLast()).<br><br>this seems to work so far... <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top