The technique of combining many small operations together into one large batch has a proud heritage in computing, and dates all the way back to the time when jobs were submitted to computers in the form of punched cards. You will be pleased to know that SQLJ has similar facilities for batching database operations.
You can get SQLJ to buffer identical SQL INSERT, UPDATE, or DELETE statements in your SQLJ programs into a batch, which is then submitted to the database. This reduces the number of round trips made to the database over the network, and may lead to an improvement in performance.
One candidate for batching is a SQL statement contained within a loop. Another is a method that is run repeatedly and contains a SQL statement. In this section, I explain how to control and run batches in your SQLJ programs.
Batching is a feature you control through an execution context. (Execution contexts were discussed in Chapter 8.) By default, batching is not enabled. To enable batching for an execution context, call the method setBatching( ). This method accepts a Boolean true or false value indicating whether or not batching should be enabled. The following statements first create an execution context named my_exec_context, and then ...