SQL 语句改成 select count(id) as cnt from news
然后通过 rs("cnt") 就可以得知行数

解决方案 »

  1.   

    还有一个直接插入你的代码的解决方案,
    rs.last();//光标移到最后一条记录
    count=rs.getRow();//得到最后一条记录的行号
    简单吧
      

  2.   

    rs.last();//光标移到最后一条记录
    这种做法,是可以得出。但如果记录太多的话,这样会非常不好的,不但浪费资源,也浪费时间。
      

  3.   


     setResultSetScrollType(ResultSet.TYPE_SCROLL_INSENSITIVE); //让结果集可前后滚动
                rset = executeQuery(selectSQL);
        /**
         * 使结果集可前后滚动, 在执行 prepareStatement(String SQL) 方法前调用
         * 
         * @param iScrollType
         *            int
         */
        public synchronized void setResultSetScrollType(int iScrollType)
        {
            resultSetScrollType = iScrollType;
        }            rset.last();            iRowCount = rset.getRow();//取得行
                iColCount = rset.getMetaData().getColumnCount();//取得列
    你在倒序去值
                for(int i = iRowCount; i > 0; i--)
                {
                    for(int j = 0; j < iColCount; j++)
                    {
                        orderSet[i - 1][j] = rset.getString(j + 1);
                    }                rset.previous();
                }
      

  4.   

    用完一定要把rs 在设置回去
            finally
            {
                setResultSetScrollType(iScrollType); //让结果集回到旧的状态
            }