说什么?
将游标移到第一行前beforeFirst
public void beforeFirst()
                 throws SQLExceptionMoves the cursor to the front of this ResultSet object, just before the first row. This method has no effect if the result set contains no rows.
Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY
Since: 
1.2

解决方案 »

  1.   

    resultset没有查到数据,是不是得beforeFirst()一下,不然会不会出错!
      

  2.   

    要使用resultset的这个方法,首先在得到这个resultset的时候必须把statement声明成为scrollable,例如:
    PreparedStatement stmt = connection.prepareStatement(sql, para1, para2);
    其中para1和para2可以使用ResultSet类中的常量。
    另外,在resultset没有数据的时候,无需调用这个方法,因为resultset默认就是处于这个位置。
      

  3.   

    怎么 把statement声明成为scrollable,
    对不起,本人新手。
    也不知道scrollable 是什么样的接口,请说明,非常感谢!
      

  4.   

    用带参数的方式打开一个stmt
    stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);