NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)
Cached Row Sets
CachedRowSet components support JavaBeans events, which allows other JavaBeans components in an application to be
notified when an important event on a row set occurs. A component that wants to register for CachedRowSet events must
implement the RowSetListener interface. Event listeners are registered with a row set by calling the
addRowSetListener method. Cached row sets can generate these types of events:
Cursor movement events indicate that the row set's cursor has moved.●
Row change events indicate that a particular row has been inserted, updated, or deleted.●
Row set change events indicate that the entire contents of a row set have changed.●
A cached row set might or might not maintain an open database connection. Cached row sets extend ResultSet (by
implication scalable, updatable result sets).
Cached Row Sets at Run Time
A cached row set has a command property that is used to populate the row set. The SQL command can optionally accept input
parameters. Typically, the command property is specified a design time, while parameters are not set until run time when their
values are known.
Traversing a Cached Row Set
Because javax.sql.RowSet extends java.sql.ResultSet, in many ways a cached row set behaves just like a result
set. A CachedRowSet is simply a ResultSet that can function as a JavaBeans component. An application iterates through
a row set by invoking result set methods, such as beforeFirst() and Next().
Command Execution
A cached row set can be filled with data by calling the CachedRowSet.execute() method. The execute() method
uses the appropriate property values (DataSource, Concurrency, Command, Type, ReadOnly, and so on) to
connect to a data source and to retrieve some data. The exact properties that must be set can vary between CachedRowSet
implementations. For NonStop
TM
Server for Java, the following properties must be set:
DataSource or URL●
Command●
All other properties default as follows:
Concurrency defaults to CONCUR_READONLY.●
MaxFieldSize defaults to zero (that is, unlimited).●
MaxRows defaults to zero (unlimited).●
Password defaults to none.●
QueryTimeOut defaults to zero (unlimited).●
ReadOnly defaults to true (it is read-only).●
TransactionIsolation defaults to TRANSACTION_READ_COMMITTED.●
UserName defaults to none.●
Execution Scenarios
NonStop
TM
Server for Java can be executed as any of the following:
Stand-alone process●
Web-based servlet●
Invoked from C or C++ code●
Invoked from the Java RMI API●