Why is “while (rs.next())” necessary here?

前端 未结 5 1403
夕颜
夕颜 2021-01-07 16:08

I want to select the maximum line number from my database \"Logs\" and store it in a variable m.

Here\'s my code:

ResultSet rs          


        
5条回答
  •  忘掉有多难
    2021-01-07 16:51

    You can convert this to use a simple if statement instead.

    if(rs.next()) {
        // other code here
    }
    

    You would use while when you have more than one row to bring back.

提交回复
热议问题