Java Reference
In-Depth Information
 
setUrl — used with DriverManager access
 
setUsername
 
setPassword
 
setTransactionIsolation
You need only set those properties that are needed for your particular use of a
RowSet.
The following lines of code make the CachedRowSet object crset scrollable and
updatable.
CachedRowSet crset = new CachedRowSet();
crset.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
crset.setConcurrency(ResultSet.CONCUR_UPDATABLE);
crset.setCommand("SELECT * FROM Customers");
crset.setDataSourceName("jdbc/customers");
crset.setUsername("myName");
crset.setPassword("myPwd");
crset.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
crset.addRowSetListener(listener);
If the DriverManager were being used to make a connection, you would set the
properties for a JDBC URL, a user name, and a password. The preferred means of
getting a connection is to use a DataSource object with the owner's user name and
the owner's password.
Now that the CachedRowSet has been created and initialized, all that remains is to
call the execute() method; the RowSet uses the information in its properties to make a
connection and execute the query. The data in the RowSet can then be accessed
and updated.
Rowset Events
A RowSetEvent is generated when something important happens in a RowSet, such
as a change in a column value. Being JavaBeans, RowSets can use the Java event
model to notify listeners when the RowSet is changed.
These are the RowSetListener methods:
 
rowChanged (Called when the RowSet is changed)
 
rowSetChanged(Called when a RowSet is inserted, updated, or deleted)
 
cursorMoved (Called when a RowSet's cursor is moved)))
Search WWH ::




Custom Search