user7006602
user7006602

Reputation:

I'm confused with the role of method called .next() in java and jdbc

I use .next() in java string to return the value what comes before white_space

e.g. "hello world"=> returns "hello"

But in jdbc:

ResultSet rs= stmt.executeQuery();
if(rs.next()){ 
     //do something
}

I use it with the moto

"If the result set still has results, move to the next result and do something"

So I'm confused with the role. Please someone clarify it.

Upvotes: 0

Views: 88

Answers (1)

user85421
user85421

Reputation: 29710

All standard Java classes are documented: Java API Specification.

Example:

  1. ResuttSet.next()

    Moves the cursor forward one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on.

    ...

  2. Scanner.next()

    Finds and returns the next complete token from this scanner. A complete token is preceded and followed by input that matches the delimiter pattern.

    ...

Upvotes: 2

Related Questions