| Propagates changes in the given RowSet object
back to its underlying data source and returns true
if successful. The writer will check to see if
the data in the pre-modified rowset (the original values) differ
from the data in the underlying data source. If data in the data
source has been modified by someone else, there is a conflict,
and in that case, the writer will not write to the data source.
In other words, the writer uses an optimistic concurrency algorithm:
It checks for conflicts before making changes rather than restricting
access for concurrent users.
This method is called by the rowset internally when
the application invokes the method acceptChanges .
The writeData method in turn calls private methods that
it defines internally.
The following is a general summary of what the method
writeData does, much of which is accomplished
through calls to its own internal methods.
- Creates a
CachedRowSet object from the given
RowSet object
- Makes a connection with the data source
- Disables autocommit mode if it is not already disabled
- Sets the transaction isolation level to that of the rowset
- Checks to see if the reader has read new data since the writer
was last called and, if so, calls the method
initSQLStatements to initialize new SQL statements
- Builds new
SELECT , UPDATE ,
INSERT , and DELETE statements
- Uses the
CachedRowSet object's metadata to
determine the table name, column names, and the columns
that make up the primary key
- When there is no conflict, propagates changes made to the
CachedRowSet object back to its underlying data source
- Iterates through each row of the
CachedRowSet object
to determine whether it has been updated, inserted, or deleted
- If the corresponding row in the data source has not been changed
since the rowset last read its
values, the writer will use the appropriate command to update,
insert, or delete the row
- If any data in the data source does not match the original values
for the
CachedRowSet object, the writer will roll
back any changes it has made to the row in the data source.
true if changes to the rowset were successfullywritten to the rowset's underlying data source;false otherwise |