Batch Processing using Prepared Statement in Java

Batch processing is a feature in JDBC used to club multiple SQLs and send it to database in one call.

You can get more details on Batch Processing here

Advantages of Batch processing

1. Performance
Batch processing can reduce a lot of performance overhead, as all the SQL statements are send in one database call.

2. Transaction Management
Imagine you have 50 SQL statements to be fired and if any one of the SQL fails during execution, then revert all other changes.
This can be achieved using batch processing.

Return value of executeBatch()

executeBatch() returns an array of update counts containing one element for each SQL that was added in the batch according to the order of which they were added.

Now lets see an example of Batch Processing using Statement in Java

Example : Batch Processing using Prepared Statement