select count(*) from table

解决方案 »

  1.   

    用rs.last()会出错:出错提示为:对只转发结果集的无效操作: last
      

  2.   

    select count(*) from table
      

  3.   

    rs.last();
    rs.getRow();
    这个方法是可行的,不过我现在改变我的程序结构后就不行了,期待
      

  4.   

    jdbc2.0使用记录集的滚动才可以,jdbc1.x肯定不行,只能用count(*)的方法
      

  5.   

    可以用sun的新包rowset
    cacherowset crs;
    crs.getrow();
    非常好用
      

  6.   

    public int getsqlnum(String s)
        {
            int i = 0;
            try
            {
                ResultSet rs1;
               if(conn != null)
                    conn.close();
                conn = DriverManager.getConnection(sConnStr, UseName, PassWord);
                Statement statement = conn.createStatement();
                rs1 = statement.executeQuery(s);
                while(rs1.next())
                {
                    i ++;
                }
                rs1.close();
            }
            catch(SQLException sqlexception)
            {
                System.out.print("getsqlnum error" + sqlexception.getMessage());
                return 0;
            }
            return i;
        }请大伙帮我看看有什么问题?
      

  7.   

    只能自己用sql语句来取了
    select count(*) as count from tableint count=rs.getInt("count");
      

  8.   

    jdbc2.0以上用
    rs.last();
    rs.getRow();jdbc2.0以下用select count(*) ...
      

  9.   

    用rs.last()会出错:出错提示为:对只转发结果集的无效操作: last
    是因为jdbc版本太低用selcet count(*)