如果你的jdbc驱动的版本够的话可以使用rs.isFirst() 和rs.isLast()

解决方案 »

  1.   

    ResultSet rs = psm.executeQuery();
        rs.isFirst();
        rs.isLast();
      

  2.   

    谢谢回复
    我调用后rs.isFirst(); 返回
    org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.isFirst
    是jdbc驱动的版本不够?
    需要多少版本?如何查看自己的JDBC版本
      

  3.   

    rs.isFirst() 和 rs.isLast()
      

  4.   

    if(rs.isFirst()&&rs.isLast())
    {...}
      

  5.   

    变通一下嘛,你可以再用一条SQL语句得到记录的条数,然后再int curCount=1;
    while(rs.next()){if(curCount==totalCount){//如果是最后一条}else{//如果不是最后一条
    }curCount++;
    }
      

  6.   

    下面的也许对你有帮助
    createStatement
    public Statement createStatement(int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLExceptionCreates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability. This method is the same as the createStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden. Parameters:
    resultSetType - one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
    resultSetConcurrency - one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
    resultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
      

  7.   

    建立Statement用如下的语句就可以使用isFirst()和isLast()方法了Statement pstmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);