Updatable Result Sets
If
you
remember scrollable result sets from Chapter 3, you may recall that one of the parameters you
used to create a scrollable result set was something called the
result set concurrency
. So far, the statements in this
book have used the default concurrency,
ResultSet.CONCUR_READ_ONLY. In other words, you
cannot make changes to data in the result sets you have seen without
creating a new update statement based on the data from your result
set. Along with scrollable result sets, JDBC 2.0 also introduces the
concept of updatable result sets—result
sets you can change.
An updatable result set enables you to perform in-place changes to a result set and have them take effect using the current transaction. I place this discussion after batch processing because the only place it really makes sense in an enterprise environment is in large-scale batch processing. An overnight interest-assignment process for a bank is an example of such a potential batch process. It would read in an accounts balance and interest rate and, while positioned at that row in the database, update the interest. You naturally gain efficiency in processing since you do everything at once. The downside is that you perform database access and business logic together.
JDBC 2.0 result sets have two types of concurrency:
ResultSet.CONCUR_READ_ONLY
and
ResultSet.CONCUR_UPDATABLE
. You already know how to
create an updatable result set from the discussion of scrollable
result sets in Chapter 3. You ...
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