while(rs.next())
{
    rs.isLast();
}
想判断结果集是不是最后一条!为什么会错呢?怎么改?请高手指教!

解决方案 »

  1.   

    把API先贴出来给你看看public boolean isLast() throws SQLException
    Retrieves whether the cursor is on the last row of this ResultSet object. Note: Calling the method isLast may be expensive because the JDBC driver might need to fetch ahead one row in order to determine whether the current row is the last row in the result set. Returns:
    true if the cursor is on the last row; false otherwise 
    Throws: 
    SQLException - if a database access error occurs
    我觉得是不是:
    while(rs.next()){
     if(rs.isLast()==true){
      dosomething....
    }
    }
      

  2.   

    本身rs.isLast()返回的就是boolean,还用再和true比较吗?
    在我的程序里面:
    while(rs.next())
    {
        if(rs.isLast())
        {
        }
    }就出现错误。
    如果:
    while(rs.next())
    {
        rs.isFirst();
        {
        }
    }
    没问题!