JAVA中rs是什么意思_方法:rs.absolute(...)和rs.isAfterLast()是什么意思??谢谢

请问大虾:

import java.sql.*;中

ResulSet rs

rs.absolute(...) ///1

rs.isAfterLast()///2

这两个函数有什么用处,我不懂,请教教我吧?谢谢

|

rs.absolute(...)允许你指定结果集的绝对位置

如果没有它,假如你要取第1000条记录的数据,就只能rs.next()1000次了:)

rs.isAfterLast()是一种特殊的状态,表征已到达结果集的结尾,此时你如果调用rs.next()就会抛出异常

|

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

|

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 SQLException

Moves 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 SQLException

Indicates 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

|

sql相关基本方法的使用:

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()方法前光标所在行

给分!!!!

|

按时结账很重要----------------

1、分可以体现csdn各会员对论坛的热心程度及帮助他人的爱心程度,在表示谢意的同时也可以营造更好的互相帮助的氛围。

2、一个贴子老是不结账,回答过问题的和将回答问题的人不知道你的问题解决了没有,不利于问题的解决。

3、对于其他有相关疑问的后来者,搜索到这个问题时,不能肯定此问题答案的正确与否,可能还要提问。一方面起不到资源共享的效果,另一方面,类似的问题反复的提问,影响了论坛中真正没解决的问题关注率,问题不能及时的得到回复,影响了论坛的凝聚力,反过来会造成提问者也不爱帮助他人的不友好心态。

4、.....

5、.....

.....

.....

@%$#%$^%$@^%$^%$........唐僧姐姐,饶了我吧,已经吐血了....

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值