Using java.sql and official oracle documentation does not state this explicitly but I feel like successive update queries do not update db automatically after using a method that performs a transaction using setAutoCommit(false)
, commit()
and rollback()
, do I have to call setAutoCommit(true)
after calling either commit()
or rollback()
?
EDIT: can confirm that calling setAutoCommit(true) after performing the transaction produces the correct and expected behaviour
generic code that worked for me:
setAutoCommit(false);
try {
//do transaction stuff
commit();
} catch (SQLException e) {
rollback();
} finally {
setAutoCommit(true);
}
Changing the auto commit, will effect the active session, it will not revert to true after any command besides setAutoCommit(true)
.
So in short, no, you have to set it manually or reconnect, as it is set to true by default with every connection.