java.sql.SQLException: Exhausted Resultset原因分析

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

java.sql.SQLException: Exhausted Resultset
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)

出现这个错误的原因是因为ResultSet curser 指针已经在最后一个元素之外了,说明要么是ResultSet 集合为空,要么是集合已经没有可以读取的元素了,此时你再调用rs.get()获取元素,就会报错。

if (rs! = null) {
  while (rs.next()) {
    count = rs.getInt(1);
  }
  count = rs.getInt(1); //this will throw Exhausted resultset
}

转载于:https://my.oschina.net/u/2308739/blog/701164

你可能感兴趣的:(java.sql.SQLException: Exhausted Resultset原因分析)