Batch Update Example JDBC

Batch Update Example JDBC

Batch Update JDBC

If 10 records of Employee are to be inserted, writing 10 times insert command is very slow in performance as 10 times the JDBC program should hit the database. To improve the performance, all the 10 insert statements can be converted into a batch and executed at a time. In this case, JDBC hits the database only once (Hibernate framework does the job like this only) and thereby performance increases.

Example on Batch Update JDBC

executeBatch() executes all the statements included in addBatch() method.

Note 1: If the JDBC basics are not clear, it is advised to go through JDBC Programming Basic Steps where the meaning of Connection, Statement etc. are discussed.

Note 2: To know how to use try-catch-finally with the above code, example program is available at JDBC Example – Create Table.

View All JDBC Examples

Leave a Reply

Your email address will not be published. Required fields are marked *