当前位置: 代码迷 >> Java相关 >> resultSet.last()什么意思,该如何处理
  详细解决方案

resultSet.last()什么意思,该如何处理

热度:1387   发布时间:2016-04-22 21:31:24.0
resultSet.last()什么意思
resultSet.last()什么意思 与rs.next()有什么区别 什么用 谢谢

------解决方案--------------------
last是讲cursor移到最后。
看API:
boolean last()
             throws SQLException

    Moves the cursor to the last row in this ResultSet object.

    Returns:
        true if the cursor is on a valid row; false if there are no rows in the result set 
    Throws:
        SQLException - if a database access error occurs; this method is called on a closed result set or the result set type is TYPE_FORWARD_ONLY 
        SQLFeatureNotSupportedException - if the JDBC driver does not support this method
    Since:
        1.2


next是往下一行移到一个
看API:
boolean next()
             throws SQLException

    Moves the cursor froward 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.

    When a call to the next method returns false, the cursor is positioned after the last row. Any invocation of a ResultSet method which requires a current row will result in a SQLException being thrown. If the result set type is TYPE_FORWARD_ONLY, it is vendor specified whether their JDBC driver implementation will return false or throw an SQLException on a subsequent call to next.

    If an input stream is open for the current row, a call to the method next will implicitly close it. A ResultSet object's warning chain is cleared when a new row is read.

    Returns:
        true if the new current row is valid; false if there are no more rows 
    Throws:
        SQLException - if a database access error occurs or this method is called on a closed result set


------解决方案--------------------
next是将游标移动到下一个位置。last当然是移到结果的最后一行咯。根据字面意思也可以理解。
------解决方案--------------------
last是讲cursor移到最后。
next是往下一行移到一个。
  相关解决方案