Answer to Question #63005 in Java | JSP | JSF for jonney

Question #63005
explain exactly what "rs.next()" do in addition to its return value.
1
Expert's answer
2016-11-02T16:15:14-0400
When you get the result set, it cursor is under the first line. So to get the data you need first to move cursor to the first line. rs.next() shifts the cursor to the next row of the result set from the database and returns true if there is any row, otherwise returns false. It can you in a while loop like this:
if (rs.next()) {
}
You can also use additional method hasNext(), that return true is there is a next row.
if(rs.hasNext()) {
rs.next();
// do something
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS