The documentation of Statement.executeBatch()
is not clear on this, but I assume that calling it will empty the Statement
object's current list of SQL commands in the same way as clearBatch()
does. I'm also assuming the same is true for PreparedStatement
.
I suppose it is possible to continue using the Statement
after calling Statement.executeBatch()
, i.e. add another batch of commands and execute them.
Although not explicitly mentioned in the API documentation of executeBatch
, the behaviour is specified by the JDBC 4.3 Specification in section 14.1.2 Successful Execution:
The statement's batch is reset to empty once executeBatch returns.
Although this is specified in a section called 'Successful Execution', it is also the intended behaviour for unsuccessful execution.
In short, when you call executeBatch()
the current batch of statements is submitted to the database server and cleared.