JDBC Batch Processing


 

JDBC Batch Processing

In this section you will learn JDBC Batch Processing in detail with the help of example code.

In this section you will learn JDBC Batch Processing in detail with the help of example code.

JDBC Batch Processing

In this section we are discussing about JDBC Batch processing. You will learn how to write Java programs for JDBC batch processing. The JDBC Batch processing is the mechanism where a group of related SQL statements are submitted to the database in once database call. And database processing all the statements and return the information to the Java application about the batch.

This saves time and processing power as you are sending many statements in one go to the database. This also improves the overall performance of the application. So, JDBC batch processing is an important topic in learning JDBC concepts. We have given many examples to help you in mastering the JDBC Batch processing API.

Following main JDBC API is used in used in JDBC Batch processing:

  1. DatabaseMetaData: You can call DatabaseMetaData.supportsBatchUpdates() method to find status batch processing capability of the database.
  2. addBatch() method: The addBatch() method of Statement, PreparedStatement, and CallableStatement classes are used to add the individual statements to the batch.
  3. executeBatch(): The executeBatch() method finally submits the batch job to database and it returns the int value which is the rows affected with each query.
  4. clearBatch(): The clearBatch() method is used to clear (remove) all the batch statements added with the help of addBatch() method.

Learn the JBDC Batch Processing with the help of following examples.

Ads