Resultset More
In the first few sections, we introduced the use of SQL statements to make database new, update, and delete operations, using ExecuteUpdate () to perform SQL, but using ExcuteUpdate () is actually an easy error, if we just want to query Information makes some simple new, update, or delete operations, some of the RESULT's approach is performed.
To use the ResultSet to make new addresses, you must specify resultSet.Type_Scroll_Sensitive (or ResultSet.Type_Scroll_insensitive, if you don't want to get the result of updated data) and resultset.concur_updatable. Such as
Statement Stmt = Conn.createStatement (ResultSet.Type_Scroll_Sensitive, ResultSet.concur_Updata);
If we want to update your operation for the query, move the cursor to the record position you want to update, and then use Updatexxx (), etc., and finally use Updaterow () to take effect
ResultSet Result = Stmt.executeQuery ("Select * from message where name = 'michael chen'");
Result.last ();
Result.UpdateString ("email",
Ybugchen@163.com); // The first parameter field name, the second parameter value
Result.Updaterow ();
After using Updatexxx (), it will not immediately take effect on the corresponding field operation, but must perform the Updaterow () method will operate the database. If you want to cancel the UPDATEXXXXX () method before Updaterow (), then You can use the CancelRowUpdates () method.
If you want to add a record, first use MoveToInSertrow () to move to the new data, point to the corresponding updatexxxx () method, and then add a record in executing inSertrow ().
ResultSet Result = Stmt.executeQuery ("Select * from message where name = 'michael chen'");
Result.MoveInsertRow ();
Result.UpdateString ("Name", "Susan");
Result.UpdateString ("Email", "Susan@mail.com");
Result.UpdateString ("Subject", "Test");
Result.UpdateString ("Memo", "This Is A Test!");
Result.inSertrow ();
Result.movetocurrentrow ();
If you want to delete each record of the query, move the cursor to the record, execute the deleterow () method
Result.last ();
Result.deleterow ();