rs.absolute(...)允许你指定结果集的绝对位置
如果没有它,假如你要取第1000条记录的数据,就只能rs.next()1000次了:)
rs.isAfterLast()是一种特殊的状态,表征已到达结果集的结尾,此时你如果调用rs.next()就会抛出异常

解决方案 »

  1.   

    public boolean absolute(int row):
    Moves the cursor to the given row number in this ResultSet object
    就是说把ResultSet的指针移到指定的位置。public boolean rs.isAfterLast():
    Indicates whether the cursor is after the last row in this ResultSet object
    就是判断ResultSet的指针是否移到最后一行记录的后面。
    下面是jdk帮助文档上写的。absolute
    public boolean absolute(int row)
                     throws SQLExceptionMoves the cursor to the given row number in this ResultSet object. 
    If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set. The first row is row 1, the second is row 2, and so on. If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set. For example, calling the method absolute(-1) positions the cursor on the last row; calling the method absolute(-2) moves the cursor to the next-to-last row, and so on. An attempt to position the cursor beyond the first/last row in the result set leaves the cursor before the first row or after the last row. Note: Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last().Returns:
    true if the cursor is on the result set; false otherwise
    Throws:
    SQLException - if a database access error occurs, the row is 0, or the result set type is TYPE_FORWARD_ONLY----------------------------------------------------------------
    isAfterLast
    public boolean isAfterLast()
                        throws SQLExceptionIndicates whether the cursor is after the last row in this ResultSet object.
    Returns:
    true if the cursor is after the last row; false if the cursor is at any other position or the result set contains no rows
    Throws:
    SQLException - if a database access error occurs
      

  2.   

    public boolean absolute(int row):
    Moves the cursor to the given row number in this ResultSet object
    就是说把ResultSet的指针移到指定的位置。public boolean rs.isAfterLast():
    Indicates whether the cursor is after the last row in this ResultSet object
    就是判断ResultSet的指针是否移到最后一行记录的后面。
    下面是jdk帮助文档上写的。absolute
    public boolean absolute(int row)
                     throws SQLExceptionMoves the cursor to the given row number in this ResultSet object. 
    If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set. The first row is row 1, the second is row 2, and so on. If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set. For example, calling the method absolute(-1) positions the cursor on the last row; calling the method absolute(-2) moves the cursor to the next-to-last row, and so on. An attempt to position the cursor beyond the first/last row in the result set leaves the cursor before the first row or after the last row. Note: Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last().Returns:
    true if the cursor is on the result set; false otherwiseThrows:
    SQLException - if a database access error occurs, the row is 0, or the result set type is TYPE_FORWARD_ONLY----------------------------------------------------------------
    isAfterLast
    public boolean isAfterLast()
                        throws SQLExceptionIndicates whether the cursor is after the last row in this ResultSet object.Returns:
    true if the cursor is after the last row; false if the cursor is at any other position or the result set contains no rowsThrows:
    SQLException - if a database access error occurs
      

  3.   

    谢谢再问:
       有没有关于java 的函数大全,带例子的!
      

  4.   

    这本书蛮好的,<<Java 2类库>>.
    http://www.china-pub.com/computers/common/info.asp?id=1666还有就是jdk的帮助文档了,其实看这个更好,因为翻译的话有些东西总不是很精确的。
      

  5.   

    <b>sql相关基本方法的使用:</b>rs.next();//向后滚动
    rs.getRow();//得到当前行号
    rs.absolute(n);//光标定位到n行
    rs.relative(int n);//相对移动n行
    rs.first();//将光标定位到结果集中第一行。
    rs.last();//将光标定位到结果集中最后一行。
    rs.beforeFirst()//将光标定位到结果集中第一行之前。
    rs.afterLast();//将光标定位到结果集中最后一行之后。
    rs.moveToInsertRow();//光标移到插入行
    rs.moveToCurrentRow();//光标移回到调用rs.moveToInsertRow()方法前光标所在行
    <b>给分!!!!</b>
      

  6.   

    按时结账很重要----------------1、分可以体现csdn各会员对论坛的热心程度及帮助他人的爱心程度,在表示谢意的同时也可以营造更好的互相帮助的氛围。
    2、一个贴子老是不结账,回答过问题的和将回答问题的人不知道你的问题解决了没有,不利于问题的解决。
    3、对于其他有相关疑问的后来者,搜索到这个问题时,不能肯定此问题答案的正确与否,可能还要提问。一方面起不到资源共享的效果,另一方面,类似的问题反复的提问,影响了论坛中真正没解决的问题关注率,问题不能及时的得到回复,影响了论坛的凝聚力,反过来会造成提问者也不爱帮助他人的不友好心态。
    4、.....
    5、.....
    .....
    .....
    @%$#%$^%$@^%$^%$........唐僧姐姐,饶了我吧,已经吐血了....