Closed JDBC-0 closed 19 hours ago
When autocommit is true:
When autocommit is false:
Summary: True: Immediate commits for each statement. False: All statements in the batch are treated as one transaction, allowing for rollbacks on failure.
@divang : thanks - but I guess this is not always true, is it? Because it might depend on the URL Parameters like the bulkCopy feature. I guess even if autocommit is true, the bulk copy feature won't commit each single INSERT statement ... right? Does the bulk copy feature always commits all inserted rows at once with 1 single transaction? If not, the bulk copy feature wouldn't have any advantage if every single INSERT statement would be commited. Or am I missing a point?
Batch inserts done using prepared statements with URL parameter useBulkCopyForBatchInsert=true
also adhere to transactional semantics.
The inserted records are committed upon committing the transaction.
The behavior mentioned above by @divang is consistent with useBulkCopyForBatchInsert=true
also
Hi @JDBC-0,
Please let us know if you have additional questions/comments, or else we will move forward with closing this issue.
Thank you for the clarification. To avoid the same questions again, it would be very helpful to have this info in the driver documentation.
We'll look into updating docs for the next release.
Question
How does the driver execute batch INSERTs if the connection auto commit is true? The JDBC specification has no standard rule and this "is a driver specific" topic. The documentation https://learn.microsoft.com/en-us/sql/connect/jdbc/performing-batch-operations?view=sql-server-ver16 has no hint for this - so how can we be sure that our batch inserts are performed as expected (as batches - and not as single INSERTs) - if auto commit is true?