如何获得ResultSet记录集中记录的条数?
是有一个方法吧?
请高手指教!

解决方案 »

  1.   

    selet sum() as tit from tablename~~~
    在SQL语句中写个函数。
      

  2.   

    rs.last();
    int r = rs.getRow();
      

  3.   

    vb中类似的功能好像是由一个recordcount()属性可以直接查出
    不知道jsp中是否有类似的方法呢?
      

  4.   

    select count(*) from table
    rs.next();
    rs.getInt(1);
      

  5.   

    int count = 0;
    while(rs.next())
    {
       count ++;
    }
      

  6.   

    回楼上:
    sql="select distinct age from my_form";
    对于这样的select语句如何直接查出记录数呢? count(*)好像不行
      

  7.   

    方法1:
    int a=rs.getRow();
    方法2:
    int a = 0;
    while(rs.next())
    {
       a ++;
    }
      

  8.   

    select  count(distinct age )from tablename
      

  9.   

    while( rs.next() ){
    rs.getInt(1);
    }
      

  10.   


    oracle可以用函數  ,select sum(列名) from 表名
      

  11.   

    回14bn1TIGER:
    我的sql语句是这样写的:
    select distinct age, count(distinct age )from tablename
    可是结果报错呢?
      

  12.   

    女上司对我特别照顾,可我是个结过婚的人,我该怎么办?http://community.csdn.net/Expert/topic/5515/5515498.xml?temp=.4312403
      

  13.   

    sql="select distinct age from my_form";
    返回的是表my_form中不同age字段的记录,如果age相同的记录就不会返回了,所以这返回的不一定是表里所有的记录,除非字段age里没有相同的记录~
      

  14.   

    用循环显然效率不高。还是用sql语句计数是王道啊。
      

  15.   

    countrs的任何方法都不支持直接得到结果集行数
      

  16.   

    rs.last();
    int intRowCount=rs.getRow();
      

  17.   

    最简单的为什么都不用呢?
    rs.last(); 
    int   r   =   rs.getRow();
      

  18.   

    rs.last();
    int  r  =  rs.getRow();
    出错啊 大哥 
      

  19.   

    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    创建Statement对象时用这个方法
      

  20.   

    要用到游标来获取的话,必须设置游标为可进可退的
    rs.last(); 
    int  r  =  rs.getRow(); 
    必须createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);