1.Statement stmt=conn.createStatement();
将这句改为:
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,CONCUR_UPDATABLE);
你可以查一下帮助文档,
createStatement()中被重载过了,如果不加参数,则默认为不支持记录集滚动,
上面两参数的意识是说:
ResultSet.TYPE_SCROLL_SENSITIVE:可以让光标随意移动,
CONCUR_UPDATABLE:可以通过ResultSet对象操作记录集

解决方案 »

  1.   

    顶。
    接楼主帖,请问象二楼的方法是否同样适用SQL 2000 SERVER???
    用了二楼的方法是否使SQL 2000也支持rs.last()????
    多谢
      

  2.   

    createStatement()
    Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.   createStatement(int resultSetType,int resultSetConcurrency)resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
    resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE 
      

  3.   

    当while中第一次rs.previous()的时候,由于rs的cursor在最前面,它之前没有记录,当然错了。
    文档:
    previous
    public boolean previous()
                     throws SQLExceptionMoves the cursor to the previous row in this ResultSet object. Returns:
    true if the cursor is on a valid row; false if it is off the result set 
    Throws: 
    SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY
      

  4.   

    kingmaxno1(学会飞翔) ( )说的清楚!