Package Summary Overview Summary |
| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.rowset.internal.CachedRowSetWriter
public class CachedRowSetWriter
The facility called on internally by the RIOptimisticProvider
implementation to propagate changes back to the data source from which the rowset got its data.
A CachedRowSetWriter
object, called a writer, has the public method writeData
for writing modified data to the underlying data source. This method is invoked by the rowset internally and is never invoked directly by an application. A writer also has public methods for setting and getting the CachedRowSetReader
object, called a reader, that is associated with the writer. The remainder of the methods in this class are private and are invoked internally, either directly or indirectly, by the method writeData
.
Typically the SyncFactory
manages the RowSetReader
and the RowSetWriter
implementations using SyncProvider
objects. Standard JDBC RowSet implementations provide an object instance of this writer by invoking the SyncProvider.getRowSetWriter()
method.
SyncProvider
, SyncFactory
, SyncFactoryException
, Serialized Form
Constructor Summary | |
---|---|
CachedRowSetWriter()
|
Method Summary | |
---|---|
void | commit()
Makes permanent all changes that have been performed by the acceptChanges method since the last call to either the commit or rollback methods. |
void | commit(CachedRowSetImpl crs, boolean updateRowset)
|
CachedRowSetReader | getReader()
Gets the reader for this writer. |
void | rollback()
Undoes all changes made in the current transaction. |
void | rollback(Savepoint s)
Undoes all changes made in the current transaction made prior to the given Savepoint object. |
void | setReader(CachedRowSetReader reader)
Sets the reader for this writer to the given reader. |
boolean | writeData(RowSetInternal caller)
Propagates changes in the given RowSet object back to its underlying data source and returns true if successful. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachedRowSetWriter()
Method Detail |
---|
public boolean writeData(RowSetInternal caller) throws SQLException
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.
CachedRowSet
object from the given RowSet
object initSQLStatements
to initialize new SQL statementsSELECT
, UPDATE
, INSERT
, and DELETE
statements CachedRowSet
object's metadata to determine the table name, column names, and the columns that make up the primary key CachedRowSet
object back to its underlying data sourceCachedRowSet
object to determine whether it has been updated, inserted, or deleted CachedRowSet
object, the writer will roll back any changes it has made to the row in the data source. writeData
in interface RowSetWriter
caller
- the RowSet
object (1) that has implemented the RowSetInternal
interface, (2) with which this writer is registered, and (3) that called this method internally true
if changes to the rowset were successfully written to the rowset's underlying data source; false
otherwise SQLException
- if a database access error occurs public void setReader(CachedRowSetReader reader) throws SQLException
SQLException
- if a database access error occurs public CachedRowSetReadergetReader() throws SQLException
SQLException
- if a database access error occurs public void commit() throws SQLException
TransactionalWriter
acceptChanges
method since the last call to either the commit
or rollback
methods. This method should be used only when auto-commit mode has been disabled.
commit
in interface TransactionalWriter
SQLException
- if a database access error occurs or the Connection
object within this CachedRowSet
object is in auto-commit mode public void commit(CachedRowSetImpl crs, boolean updateRowset) throws SQLException
SQLException
public void rollback() throws SQLException
TransactionalWriter
rollback
in interface TransactionalWriter
SQLException
- if a database access error occurs or the Connection
object within this CachedRowSet
object is in auto-commit mode public void rollback(Savepoint s) throws SQLException
TransactionalWriter
Savepoint
object. This method should be used only when auto-commit mode has been disabled.
rollback
in interface TransactionalWriter
s
- a Savepoint
object marking a savepoint in the current transaction. All changes made before s was set will be undone. All changes made after s was set will be made permanent. SQLException
- if a database access error occurs or the Connection
object within this CachedRowSet
object is in auto-commit mode
| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |