Updating a CachedRowSet object is similar to updating a ResultSet object, but because the rowset is not connected to its data source while it is being updated, it must take an additional step to effect changes in its underlying data source. After calling the method updateRow or insertRow, a CachedRowSet object must also call the method acceptChanges to have updates written to the data source. The following example, in which the cursor is on a row in the CachedRowSet object crs, shows the code required to update two column values in the current row and also update the RowSet object's underlying data source. crs.updateShort(3, 58); crs.updateInt(4, 150000); crs.updateRow(); crs.acceptChanges(); The next example demonstrates moving to the insert row, building a new row on the insert row, inserting it into the rowset, and then calling the method acceptChanges to add the new row to the underlying data source. Note that as with the getter methods, the updater methods may take either a column index or a column name to designate the column being acted upon. crs.moveToInsertRow(); crs.updateString("Name", "Shakespeare"); crs.updateInt("ID", 10098347); crs.updateShort("Age", 58); crs.updateInt("Sal", 150000); crs.insertRow(); crs.moveToCurrentRow(); crs.acceptChanges(); NOTE: Where the insertRow() method inserts the contents of a CachedRowSet object's insert row is implementation-defined. The reference implementation for the CachedRowSet interface inserts a new row immediately following the current row, but it could be implemented to insert new rows in any number of other places.Another thing to note about these examples is how they use the method acceptChanges. It is this method that propagates changes in a CachedRowSet object back to the underlying data source, calling on the RowSet object's writer internally to write changes to the data source. To do this, the writer has to incur the expense of establishing a connection with that data source. The preceding two code fragments call the method acceptChanges immediately after calling updateRow or insertRow. However, when there are multiple rows being changed, it is more efficient to call acceptChanges after all calls to updateRow and insertRow have been made. If acceptChanges is called only once, only one connection needs to be established.
Java
Topic: JDBC
Explain method Updating a CachedRowSet Object?
Browse random answers:
What does the connection object represents?
Explain method Creating a CachedRowSet Object?
Explain Retrieving Data from a CachedRowSet Object?
Explain method Retrieving RowSetMetaData?
Explain method Updating a CachedRowSet Object?
Explain method Updating the Underlying Data Source?
Explain method Registering and Notifying Listeners?
Explain method Passing Data to Thin Clients?
Explain Scrolling and Updating?
Explain Getting Universal Data Access?
Explain Setting Properties?
Explain Paging Data?
Explain Background?
Explain Predicate Sharing?
Explain Updating a FilteredRowSet Object?
Explain Behavior of Rows Outside the Filter?
Explain Creating a JdbcRowSet Object?
Explain boolean getShowDeleted() throws SQLException?
Explain void setShowDeleted(boolean b) throws SQLException?
Explain about getRowSetWarningsRowSetWarning getRowSetWarnings() throws SQLException?
Explain about void commit() throws SQLException?
Explain getAutoCommitboolean getAutoCommit() throws SQLException?
Explain void setAutoCommit(boolean autoCommit) throws SQLException?
Explain about void rollback() throws SQLException?
Explain void rollback(Savepoint s) throws SQLException?
Explain about Managing Multiple Match Columns?
Explain about void setMatchColumn(int columnIdx) throws SQLException?
Explain setMatchColumnvoid setMatchColumn(int[] columnIdxes) throws SQLException
Explain about setMatchColumnvoid setMatchColumn(String columnName) throws SQLException?
Explain about setMatchColumnvoid setMatchColumn(String[] columnNames) throws SQLException?
Explain about getMatchColumnIndexesint[] getMatchColumnIndexes() throws SQLException
Explain about getMatchColumnNamesString[] getMatchColumnNames() throws SQLException?
Explain about unsetMatchColumnvoid unsetMatchColumn(int columnIdx) throws SQLException
Explain about unsetMatchColumnvoid unsetMatchColumn(int[] columnIdxes) throws SQLException?
Explain unsetMatchColumnvoid unsetMatchColumn(String columnName) throws SQLException?
UnsetMatchColumnvoid unsetMatchColumn(String[] columnName) throws SQLException
Using a JoinRowSet Object for Creating a JOIN
JoinRowSet Methods
Explain method CROSS_JOIN?
Explain about INNER_JOINstatic final int INNER_JOIN?
Explain the difference between LEFT_OUTER_JOINstatic final int LEFT_OUTER_JOIN?
Explain method RIGHT_OUTER_JOIN?
Explain the difference between FULL_JOINstatic final int FULL_JOIN
Explain about addRowSetvoid addRowSet(Joinable rowset) throws SQLException?
Explain about addRowSetvoid addRowSet(RowSet rowset, int columnIdx) throws SQLException?
Explain about addRowSetvoid addRowSet(RowSet rowset, String columnName) throws SQLException?
Explain about addRowSetvoid addRowSet(RowSet[] rowset, int[] columnIdx) throws SQLException?
Explain about addRowSetvoid addRowSet(RowSet[] rowset, String[] columnName) throws SQLException?
Explain about getRowSetsCollection<?> getRowSets() throws SQLException?
Explain getRowSetNamesString[] getRowSetNames() throws SQLException?
Explain toCachedRowSetCachedRowSet toCachedRowSet() throws SQLException?
Explain aboutpublic abstract class BaseRowSetextends Objectimplements Serializable, Cloneable?
Explain the difference between UNICODE_STREAM_PARAMpublic static final int UNICODE_STREAM_PARAM?
Explain the difference between BINARY_STREAM_PARAMpublic static final int BINARY_STREAM_PARAM?
Explain the difference between ASCII_STREAM_PARAMpublic static final int ASCII_STREAM_PARAM?
Explain the difference between binaryStreamprotected InputStream binaryStream?
Explain the difference between unicodeStreamprotected InputStream unicodeStream?
Explain the difference between asciiStreamprotected InputStream asciiStream?
Explain the difference between charStreamprotected Reader charStream?
Explain the difference between BaseRowSetpublic BaseRowSet()?
Explain the difference between initParamsprotected void initParams()?
Explain about addRowSetListenerpublic void addRowSetListener(RowSetListener listener)?
Explain about removeRowSetListenerpublic void removeRowSetListener(RowSetListener listener)?
Explain notifyCursorMovedprotected void notifyCursorMoved() throws SQLException?
Explain notifyRowChangedprotected void notifyRowChanged() throws SQLException?
Explain notifyRowSetChangedprotected void notifyRowSetChanged() throws SQLException?
Explain getCommandpublic String getCommand()
Explain about public void setCommand(String cmd) throws SQLException
Explain about public String getUrl() throws SQLException?
Explain about setUrlpublic void setUrl(String url) throws SQLException?
Explain getDataSourceNamepublic String getDataSourceName()?
Explain setDataSourceNamepublic void setDataSourceName(String name) throws SQLException ?
Explain getUsernamepublic String getUsername( ) ?
Explain setUsernamepublic void setUsername(String name)?
Explain getPasswordpublic String getPassword()?
Explain method setPasswordpublic void setPassword(String pass)?
Explain method setTypepublic void setType(int type) throws SQLException ?
Explain method getTypepublic int getType() throws SQLException ?
Explain method setConcurrencypublic void setConcurrency(int concurrency) throws SQLException ?
Explain method isReadOnlypublic boolean isReadOnly()?
Explain method setReadOnlypublic void setReadOnly(boolean value) ?
Explain method getTransactionIsolationpublic int getTransactionIsolation() ?
Explain method setTransactionIsolationPublic void setTransactionIsolation(int level) throws SQLException
Explain method getTypeMappublic Map<String,Class<?>> getTypeMap()?
Explain method setTypeMappublic void setTypeMap(Map<String,Class<?>> map)?
Explain method getMaxFieldSizepublic int getMaxFieldSize() throws SQLException?
Explain method setMaxFieldSizepublic void setMaxFieldSize(int max) throws SQLException ?
Explain method getMaxRowspublic int getMaxRows() throws SQLException?
Explain method setMaxRowspublic void setMaxRows(int max) throws SQLException?
Explain method setEscapeProcessingpublic void setEscapeProcessing(boolean enable) throws SQLException ?
Explain method getQueryTimeoutpublic int getQueryTimeout() throws SQLException ?
Explain setQueryTimeoutpublic void setQueryTimeout(int seconds) throws SQLException ?
Explain method getShowDeletedpublic boolean getShowDeleted() throws SQLException ?
Explain public void setShowDeleted(boolean value) throws SQLException ?
Explain method getEscapeProcessingpublic boolean getEscapeProcessing() throws SQLException ?
Explain method setFetchDirectionpublic void setFetchDirection(int direction) throws SQLException ?
Explain method getFetchDirectionpublic int getFetchDirection() throws SQLException ?
Explain method setFetchSizepublic void setFetchSize(int rows) throws SQLException ?
Explain method getFetchSizepublic int getFetchSize() throws SQLException ?
Explain method getConcurrencypublic int getConcurrency() throws SQLException ?