Reputation: 44051
I do not want to use next() since if the ResultSet is not empty, I do not want the cursor to be advanced. Is there some sort of peek() method or equivalent that will return false if the ResultSet is empty and true otherwise without affecting the record?
Edit:
I cannot call beforeFirst
because I get the following
Operation requires a scrollable ResultSet, but this ResultSet is FORWARD_ONLY
I need FORWARD_ONLY
because I'm using postgreSQL cursors
Upvotes: 3
Views: 2711
Reputation: 12684
isBeforeFirst()
returns true
if the cursor is before the first row or false
if it is in any other position or the resultset is empty.
Check out the Java API for ResultSet for isBeforeFirst()
Upvotes: 2
Reputation: 23208
You can invoke the first()
method to check if you have results in the ResultSet
. If first()
returns true, you can then call beforeFirst()
to reset the ResultSet
cursor position.
Upvotes: 1