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我想,是不是可以用rs.absolute(int i)定位cursor,然后rs.getXXX(),就可以了?

解决方案 »

  1.   

    不是!---对不起--也许我没问清楚!老大:我说的是 得到resultSet中有多少个记录!
      

  2.   

    哦,对不起,看错了:)
    多少条记录?
    只是对于resultset接口来说,没有这个method
      

  3.   

    建议好好研究一下JDBC,学一下什么叫ResultSetMetaData!
      

  4.   

    resultsetMetaData里也没取记录条数的,至少我没看到过。
      

  5.   

    是我错了。:)想象中有列就有行的。再次表示抱歉。
    那么.....是不是只有last()之后再getRow()了吧。
      

  6.   

    一个笨方法,while(re.next()){count++;}  :-)
      

  7.   

    另执行一次select count(*) from
    rs.getInt(1);
      

  8.   

    不用去研究java API,利用SQL语句完全可以解决
    先select count(*) from table_name where conditions
    然后rs.getInt(1)
    我的感觉就是,用Java搞数据库开发,一定要先把SQL语句学清楚,一点建议。
      

  9.   

    我觉得既然他问道想用resultSet拿到记录数量,那一定是有所要求的
    是在不行了,才去改sql的
      

  10.   

    难道用sql不行么?不过jdbc3.0里面有取得总数的。我认为还是用sql最好,通用
      

  11.   

    我想也还是用count之后再getInt(1)比较好!!
      

  12.   

    用 count 这样就得多执行一次数据库连接操作。 不如用
     :vrsky(星雨) (2001-6-4 18:27:00)  得0分 
    一个笨方法,while(re.next()){count++;}  :-)  
     这个循环, 当然这个循环也有它一定的缺陷性。
      

  13.   

    两者速度差距多大?我认为数据流大的话,count更快。而且负载应该都加载在数据库上,而不应该让应用程序承受太多负载
      

  14.   

    唉!就这样吧!----我想也没什么好办法了不知道jdbc3.0会不会加上这个方法
    散分了!