http://community.csdn.net/Expert/topic/3841/3841243.xml?temp=.7612421
参考一下

解决方案 »

  1.   

    总共几页,没有直接的方法,只有用
    crs.size()/crs.getPageSize()得到
      

  2.   

    直接跳转到某一页可以使用
    crs.populate(rs, n);
      

  3.   

    crs.populate(rs, n);rs哪里来的?
      

  4.   

    rs就是ResultSet啊CachedRowSet可以直接使用ResultSet里面的数据
    也就说先用以前的做法得到rs,然后populate就直接把数据放在CachedRowSet里面了
      

  5.   

    crs.size()/crs.getPageSize()不行,得到的结果总是为1
    我是用既有的connection连接来execute的crs.setCommand("select * from table");
    crs.setPageSize(pagesize);
    crs.execute(conn); 
    int j = crs.size()/crs.getPageSize();
    System.out.println(j);
      

  6.   

    我没用Resultset,那请介绍一下你的方法吧
      

  7.   

    我们现在的做法就是使用普通的ResultSet的得到所有数据
    那么可以通过populate把ResultSet里面所有数据放在CachedRowSet里面了
    那么就不需要
    crs.setCommand("select * from table");

    crs.execute(conn); 了如果要得到一共的页数,可以先用ResultSet得到一共的数据rows,然后再除以pageSize()
      

  8.   

    通过ResultSet的行数计算页数和通过
    while(crs.next()) page++ ;  //通过crs.execute()装入数据的
    得到页数,哪个方法好?
      

  9.   

    写错了,使while(crs.nextPage()) page++ ;
      

  10.   

    差不多吧!具体我没有测试过
    前者是直接调用rs.last()就能得到所有记录的行数,
    后者要循环很多次,可能前者好点。。