Batch Processing
Complex systems often require both online and batch processing. Each kind of processing has very different requirements. Because online processing involves a user waiting on application processing order, the timing and performance of each statement execution in a process is important. Batch processing, on the other hand, occurs when a bunch of distinct transactions need to occur independently of user interaction. A bank’s ATM machine is an example of a system of online processes. The monthly process that calculates and adds interest to your savings account is an example of a batch process.
JDBC 2.0 introduced new functionality to address the specific issues
of batch processing. Using the JDBC 2.0 batch facilities, you can
assign a series of SQL statements to a JDBC
Statement (or one of its subclasses) to be
submitted together for execution by the database. Using the
techniques you have learned so far in this book, account
interest-calculation processing occurs roughly in the following
fashion:
Prepare statement.
Bind parameters.
Execute.
Repeat steps 2 and 3 for each account.
This style of processing requires a lot of “back and forth” between the Java application and the database. JDBC 2.0 batch processing provides a simpler, more efficient approach to this kind of processing:
Prepare statement.
Bind parameters.
Add to batch.
Repeat steps 2 and 3 until interest has been assigned for each account.
Execute.
Under batch processing, there is no “back and forth” between the database ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access