Batch Processing in JDBC
Instead of executing a single query, we can execute a batch (group) of queries. It makes the performance fast.
The java.sql.Statement and java.sql.PreparedStatement interfaces provide methods for batch processing.
Advantage of Batch Processing
Methods of Statement interface
The required methods for batch processing are given below:
Example of batch processing in jdbc
Let's see the simple example of batch processing in jdbc. It follows following steps:
If you see the table user420, two records has been added.
Example of batch processing using PreparedStatement
It will add the queries into the batch until user press n. Finally it executes the batch. Thus all the added queries will be fired.