Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This example applies to a driver+database supporting JDBC2 techniques.
The database we use is called 'test',...
containing a 'members' table.
We create a Statement as one that will give a resultset that will NOT reflect changes made to the database by others, while we're handling the resultset.
For a dynamic set, use this instead, if it's supported.
The changes we make in the resultset will be registered in the database.
A ResultSet is updatable, provided,....
only one table is used in the corresponding query containing a primary key, that has been selected into the resultset.
If you don't want to update the resultset, use this instead, more efficient.
Determine number of rows in set.
Position the cursor at the first row of the set.
Start at the last row,...
work our way back.
We can use count for browsing the resultset, because it will not change.
We can change one row's contents,...
because the resultset is updatable.
Change in the resultset only,...
and update the database accordingly.
Add a row to the resultset+database.
Position cursor and delete the current row.
Determine what changes are visible to a sensitive set. Not many drivers seem to support all three features. In this example, all returned false (!) when we tried.