Joined: 16/02/2012 12:59:39
In batch update more than one records can be added in the database simultaneously by using the some java methods like: addBatch and executeUpdate. The batch update allows us to group sql statements together and send to the database server in one single trip
First of all we are going to describe the Batch Update. A batch update is a collection of multiple update statements that provides the facility for submitting in the database as a batch.
Description of program:
In this program firstly we have to establish the connection with MySQL database by using the JDBC driver. When the connection has been established we need to give the query in the prepareStatement method and it returns PreparedStatement object. The data is submitted in a batch by the addBatch method and updates it by using the executeBatch method of the PreparedStatement interface. If all records will get added in the database then it will display a message "Added Successfully!" and if any problem arises then it throws an BatchUpdateException and it shows "SQL statement is not executed!".