moveToInsertRow
public void moveToInsertRow()
                     throws SQLException
Moves the cursor to the insert row. The current cursor position is remembered while the cursor is positioned on the insert row. The insert row is a special row associated with an updatable result set. It is essentially a buffer where a new row may be constructed by calling the updater methods prior to inserting the row into the result set. Only the updater, getter, and insertRow methods may be called when the cursor is on the insert row. All of the columns in a result set must be given a value each time this method is called before calling insertRow. An updater method must be called before a getter method can be called on a column value. 这是这个方法的说明,你的那个表中就只有三列吗?

解决方案 »

  1.   

    没有,还有几列吧,可是并不是必须要填写的,只有"ID","NAME"这两个列我在数据库中设置了是不能为空的.应该跟这个没什么关系吧,我前面使用Sql语句进行更新的时候,也没有为全部字段赋值,可是依然能够插入一行啊!还是要请诸位帮忙,小弟不甚感激.
      

  2.   

    All of the columns in a result set must be given a value each time this method is called before calling insertRow.
    你没有看到这行信息吗?你说的那两行是数据库中的要求,不是这个API的要求。
      

  3.   

    这位大哥说得确实很有道理,我确实是疏忽了这一点.好像进行插入操作的时候,要对所有的列都设置值,我使用CachedRowSet已经实现了,谢谢这位大哥.可是小弟还有一个问题,还是上面的这个ResultSet有关的,对于ResultSet进行相关的操作(就是上面的插入操作),这次我是对所有的列都设置了值,但是其还是提示: "对只读结果集的无效操作: moveToInsertRow".但是对于结果集的设置,好像就是这段程序就是可以啦:Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);  不知道是不是还有别的地方要设置,请诸位赐教啊!