ResultSet 只能检索
update    用于修改

解决方案 »

  1.   

    A set of updateXXX methods were added to this interface in the JDBC 2.0 API (JavaTM 2 SDK, Standard Edition, version 1.2). The comments regarding parameters to the getXXX methods also apply to parameters to the updateXXX methods. The updateXXX methods may be used in two ways: 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 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();
      

  2.   

    我知道原因了,不能用select * ,必须指明具体的列名,如select roleid,rolename,tag from role。
    另外,select两个表得出的ResultSet是只读的,不能进行updateRow操作。是这样吗?