Resultset has no method for hasNext. I want to check if the resultSet has any value
is this the correct way
if (!resultSet.next() ) {
System.out.println("no data");
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s correct, initially the
ResultSet‘s cursor is pointing to before the first row, if the first call tonext()returnsfalsethen there was no data in theResultSet.If you use this method, you may have to call
beforeFirst()immediately after to reset it, since it has positioned itself past the first row now.It should be noted however, that Seifer’s answer below is a more elegant solution to this question.