Skip to content
Sharp

SQL for Java Devs · interview question

In a JDBC batch process, how can you ensure that all statements in the batch are executed within a single transaction?

Multiple choiceMediumchapter-8-curatedpremiumsql-for-java-devsbatching
Choose one answer
Answer and explanation

Correct answer

B. Set auto-commit to false and manually commit after executeBatch().

Why

By setting auto-commit to false and manually committing after executeBatch(), you ensure that all statements in the batch are executed within a single transaction. This prevents partial updates and maintains data consistency.

Test yourself on SQL for Java Devs

A free test with instant, explained results. No account needed.

Start free test
All SQL for Java Devs questions →