Specifically: Begin transaction // use a program to control the transaction.
// Connect database
Update the first row
// Update successfully
Update the second row
// Fail to update due to Connection lost.
How can I implement the first updated data in roll back. Test code: C. setautocommit (false );
Preparedstatement S = C. preparestatement ("insert into a values (?) ");
Savepoint S1 = C. setsavepoint ();
S. setstring (1, "333 ");
S.exe cuteupdate ();
Savepoint S2 = C. setsavepoint ();
S. setstring (1, "444 ");
S.exe cuteupdate ();
Savepoint S3 = C. setsavepoint ();
S. setstring (1, "555 ");
S.exe cuteupdate ();
C. rollback (S3 );
C. Commit ();
After debugging to update 444, manually disconnect the database and execute update 555, a familiar error will be reported: Java. SQL. sqlexception: Io exception: Connection reset by peer: Socket write error connects the database and queries Table A. The data in table A is empty, which indicates that both table 333 and table 444 are not saved. As long as setautocommit (false) is used, it will not be saved. The savepoint of Oracle is default and does not require any operations. However, if the when exception is used in SQL, the situation changes completely. Reference http://dev2dev.bea.com.cn/bbs/thread.jspa? Forumid = 123 & threadid = 42438 & messageid = 248011 #248011