Row Set
This chapter describes functions related to row sets provided by tbJDBC.
A row set is an object that includes a set of row data. It can be accessed using the javax.sql.RowSet object.
There are three kinds of row sets.
Cached Row Set(tbJDBC currently provides this row set only.)
JDBC Row Set
Web Row Set
Row Set Listener
Multiple listeners can be registered to a row set. To register a listener, the addRowSetListener() method is used, and to delete a listener, the removeRowSetListener() method is used. The listener must be implemented using the javax.sql.RowSetListener interface.
The RowSetListener interface provides the following events.
cursorMoved
Occurs whenever a row is moved using the next() or previous() method.
rowChanged
Occurs when a new row is added, or an existing row is modified or deleted.
rowSetChanged
Occurs when the entire row set is created or modified.
The events of the RowSetListener interface are used as follows:
Create a listener class.
Register the listener to a list of RowSet objects.
Cached Row Set
A Cached Row Set is a row set that stores all rows in a cache, and is not connected to the database. In tbJDBC, a Cached Row Set is provided as the TbCachedRowSet class.
Creating a RowSet Object
A RowSet object is initialized using the execute() method, and can then be used in the same way as a java.sql.ResultSet object.
This section describes two ways to create a RowSet object.
Creating a RowSet Object Using a Query
The following example illustrates how to create a RowSet object using a query.
Create a TbCachedRowSet.
Specify the URL, user name, password, and query, and then create a RowSet object by calling the execute() method.
Creating a RowSet Object using a Result Set
The following example shows how to create a RowSet object using an existing result set.
Create a TbCachedRowSet object.
Create a RowSet object by calling the populate() method with a result set object (rset).
Searching Rows
It is possible to search rows by moving forward or backward with a RowSet object.
The following is an example.
It is also possible to insert, delete, or modify rows. The acceptChanges() method must be called to commit any changes.
The following is an example.
Restrictions
The restrictions on row sets are the same as those for updatable result sets.
Last updated