execute Batch() method of Prepared Statement is * used to run batch queries in Java JDBC.
*/So JDBC batch insert and update does gives us better performance over queries running without batches.
For those who doesn’t know what is batch insert and update, Java provides several ways to execute SQL queries, one of them is JDBC batch insert and update, on which instead of executing sql query one by one using either or Prepared Satement, you execute query in batch and send a batch of query to database for execution instead of single query.
Since multiple queries are combined into batch and one batch is sent to database instead of individual queries, it reduce database round trip by factor of batch size.
You can connect to any other database such as MYSQL, SQL Server, Oracle etc using the same JDBC preparedstatement syntax.
Here is my table definition for OHEAD Field Type Size Key Text X1DEL Char 1 Status X1CMP Zoned 3,0 1 Company No.
In addition, it adds a set of methods that are needed for setting the values to be sent to the database in place of the placeholders for IN parameters.
Also, the three methods execute, execute Query, and execute Update are modified so that they take no argument.
The Statement forms of these methods (the forms that take an SQL statement parameter) should never be used with a Prepared Statement object.
I am going to use Table OHEAD in DB2 database for all my examples here.
JDBC API in Java allows program to batch insert and update data into database, which tends to provide better performance by simple virtue of fact that it reduce lot of database round-trip which eventually improves overall performance.