这样
int count;
while(rs.next()){count++;}

解决方案 »

  1.   

    statement.getResultSet().getMetaData().getColumnCount()
      

  2.   

    没有见过直接取到函数或列数的函数
    我个人办法:
    取行数:1.执行select count(*)查询,getInt(1)的返回值就是行数
            2.将rs.last();然后取rs.getRow();
    取列数:   rs = stmt.executeQuery("select * from news");
       if(rs.next()){
    int ii = 0;    
    while(true){
    try{
    ii++;
    rs.getObject(ii,stmt.getConnection().getTypeMap());
    //System.out.println(ii);
    }
    catch(SQLException e){
    ii--;
    System.out.println("列数为:"+ii);
    return;
    }

         }
       }
      

  3.   

    ...
    Statement ste=connection.createStatement(ResultSet.TYPE_CASE_INSENSITIVE,
    ResultSet.CONSOL_READ_ONLY);
    ResultSet rs=ste.createQuery("select * from test");
    rs.last();
    int count=rs.getRows();
      

  4.   

    Statment stmt = conn.creatStatment();          
    ResultSet rs = stmt.executeQuery("SELECT * FROM "+ tableName);
    ResultSetMetaData rsmd = rs.getMetaData();
    int columnCount =  rsmd.getColumnCount();
      

  5.   

    rs.last();
    int count=rs.getRows();
      

  6.   

    A default ResultSet object is not updatable and has a cursor that moves forward only.Thus, you can iterate through it only once and only from the first row to the last row. 
    所以用
    rs.last();
    int count=rs.getRows();
    将不能再进行数据的平铺.