Warm tip: This article is reproduced from stackoverflow.com, please click
java jdbc oracle

Is the executeBatch() performed on Oracle is done in order?

发布于 2020-04-10 16:05:45

This is more of a kind of theory question to understand how the executeBatch() request is handled by Oracle.

Consider there are three insert statements (PreparedStatement) ,say statement 1, statement2 and statement 3 are added to execute as a batch using executeBatch() method and over Oracle. Will there be a chance that the execution of statement 2 to complete even before statement 1 completes? In other words, can the insert operation by statement 2 succeed before the insert performed by operation ?

Provided Autocommit is set to false.

Thanks in Advance.

Questioner
user2813978
Viewed
70
Adrian Shum 2014-11-20 17:34

Provided auto-commit set to false

Then the answer is straight-forward if you are concerning on querying in the middle of insert (as you have mentioned in comment on another answer):

Given that in same connection, you cannot do query before your previous insert statement finished, that means your query needs to be from another connection.

In Oracle, before any insert/update/delete is committed, the change is not visible to other connection. That means, the query will see the snapshot before any insert is done, until you commit the change.

Then you should have no concern about the insert order in such aspect.