According to the JDBC specification the exact behavior of a batch execute with auto-commit enabled is implementation defined. So it depends on the database and its driver, and it is better to not make assumptions on the exact behavior and disable auto-commit when using batch executes.
JDBC 4.1, section 14.1.1 says:
The commit behavior of executeBatch
is always implementation-defined when an error occurs and auto-commit is true.
This only says something about the behavior for error conditions, but the implication is that individual statements might already have been committed when another statement in the batch throws an exception.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…