1. to update a column value in the current row. In a scrollable ResultSet object, the cursor can be moved backwards and forwards, to an absolute position, or to a position relative to the current row. The following code fragment updates the NAME column in the fifth row of the 
ResultSet object rs and then uses the method updateRow to update the data source table from which rs was derived.       rs.absolute(5); // moves the cursor to the fifth row of rs
       rs.updateString("NAME", "AINSWORTH"); // updates the 
          // NAME column of row 5 to be AINSWORTH
       rs.updateRow(); // updates the row in the data source
 
2. to insert column values into the insert row. An updatable ResultSet object has a special row associated with it that serves as a staging area for building a row to be inserted. The following code fragment moves the cursor to the insert row, builds a three-column row, and inserts it into rs and into the data source table using the method insertRow.       rs.moveToInsertRow(); // moves cursor to the insert row
       rs.updateString(1, "AINSWORTH"); // updates the 
          // first column of the insert row to be AINSWORTH
       rs.updateInt(2,35); // updates the second column to be 35
       rs.updateBoolean(3, true); // updates the third row to true
       rs.insertRow();
       rs.moveToCurrentRow();

解决方案 »

  1.   

    如果你的数据库驱动支持JDBC2.0或以上,当然可以啦。否则,绝对不行哦。哎,好像即使是现在很多数据库的驱动都只是部分支持JDBC2.0啊。
      

  2.   

    先确定你JDBC的版本,我从jdk1。3文档查的应该没有错!
      

  3.   

    xmvigour(微电)关注
    con = DriverManager.getConnection(url,"sa", "sa");
    stmt = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);                            
    ResultSet rs = stmt.executeQuery("select payment from employee");
    //从员工表里选出工资字段
    rs.absolute(1); //定位到第一条纪录
    rs.updateInt(1,25);//更改第一个字段的值
    rs.updateRow();//执行更新操作
    结果出错:odbc驱动程序:无效的属性/选项标识符
      

  4.   

    tatement stmt = con.createStatement(
                                          ResultSet.TYPE_SCROLL_INSENSITIVE,
                                          ResultSet.CONCUR_UPDATABLE);////here,look at here!
           ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
           // rs will be scrollable, will not show changes made by others,
           // and will be updatable