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 }
Comments
Leave a comment