当前位置: 动力学知识库 > 问答 > 编程问答 >

jsp - java.sql.SQLException: Exhausted Resultset in jdbc error

问题描述:

This question already has an answer here:

  • java.sql.SQLException: Exhausted Resultset

    7 answers

网友答案:

It seems like your result set has fewer than seven rows, so you run out of them in the for loop. It's a good idea to check rs.hasNext() to see if there are any more rows to process.

网友答案:

You didn't show the relevant piece of code (but it's visible in the screenshot), which is the while loop preceding the for loop you included:

while (rs.next()) {
    blah blah blah
}

That loop reads all rows from the SQL select statement, leaving the ResultSet fully consumes (aka exhausted).

When you then rs.getInt(i) after rs.next() returned false, you are told, "sorry, no can do, you already used all the data", aka SQLException: Exhausted Resultset.

分享给朋友:
您可能感兴趣的文章:
随机阅读: