java - What happens to my JDBC transaction if I lose my session -
i'm connecting oracle java program, , doing following:
start session
start transaction
insert bunch of rows, call stored procedures, etc.
commit transaction
end session
so . . . happens if lose session (due network problems or somewhat) in middle of transaction? automatic rollback? rollback when transaction times out? worried db going in inconsistent state until oracle gets around cleaning up.
if session lost during execution of transaction oracle database automatically rollback changes. can read more statement level atomicity in documentation. if lose transaction because of network problem ora-03113: end-of-file on communication channel
, transaction has been rolled on database.
however, true when session lost on database server itself. distributed transactions (xa) database transaction stays alive while jdbc session gone, aware of when have xa transactions.
also watch out auto-commit default turned on in jdbc driver. automatically commits every operation perform if have longer going transaction 10 inserts , 9th inserts fails, insert 1 - 8 have automatically been committed , won't rolled anymore. auto-commit can turned off via connection.setautocommit(false);
, see setautocommit in jdbc api documentation
Comments
Post a Comment