Batch processing in JDBC applications
Instead of updating one row at a time, we can also update multiple rows simultaneously. We can create a batch from a set of statements and execute them at once. This is mainly done for better performance, as compared to updating a single row at a time. We can only create a batch for similar update statements (also known as batch-compatible statements). All statements must have similar types of input parameters. Either all statements should have input parameters or none of them should have input parameters.
Getting ready
A batch update can be done by using the following methods on the PreparedStatement
object.
addBatch()
executeBatch()
clearBatch()
How to do it...
A batch can be created for a Statement
object or ...
Get IBM DB2 9.7 Advanced Application Developer Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.