Cherry
Cherry

Reputation: 33534

Where jdbc Rowsets are used?

There are some JDBC Rowsets like CachedRowSet, WebRowSet, FilteredRowSet and JoinRowSet. Does any bode know where they are used? Ok, may be CachedRowSet is good where I do not want open and connection, may be WebRowSet good when I need insert some XML data ("may be" but I do not sure). But what about others?

Obviously, It is better for performance to write join in SQL query instead of create 2 JoinRowSet, take all data from they and join fields in java. The same about FilteredRowSet - it is more efficient to add where clause to the SQL query instead of grub a lot of the data and filtered it by java.

But somebody "invented" CachedRowSet, WebRowSet, FilteredRowSet and JoinRowSet why? Does anybody has some good experience about they usage?

Upvotes: 6

Views: 1423

Answers (3)

Sachin Hadke
Sachin Hadke

Reputation: 1

Not sure but this is what I think about FilteredRowSet. One can get the data from database by making connection in one shot. For example data for city, state and country. Later one can further subset the data with out going back to database in Java. Such as all records related to city or state or country or combination of them.

Upvotes: 0

Ajay Kumar
Ajay Kumar

Reputation: 5233

The CachedRowSet interface defines the basic capabilities available to all disconnected RowSet objects. The other three are extensions of the CachedRowSet interface, which provide more specialized capabilities. The following information shows how they are related:

A CachedRowSet object has all the capabilities of a JdbcRowSet object plus it can also do the following:

  • Obtain a connection to a data source and execute a query.
  • Read the data from the resulting ResultSet object and populate itself with
    that data.
  • Manipulate data and make changes to data while it is
    disconnected.
  • Reconnect to the data source to write changes back to it.
  • Check for conflicts with the data source and resolve those
    conflicts

A WebRowSet object has all the capabilities of a CachedRowSet object plus it can also do the following:

  • Write itself as an XML document
  • Read an XML document that describes a WebRowSet object

A JoinRowSet object has all the capabilities of a WebRowSet object (and therefore also those of a CachedRowSet object) plus it can also do the following:

  • Form the equivalent of a SQL JOIN without having to connect to a data source

A FilteredRowSet object likewise has all the capabilities of a WebRowSet object (and therefore also a CachedRowSet object) plus it can also do the following:

  • Apply filtering criteria so that only selected data is visible. This is equivalent to executing a query on a RowSet object without having to use a query language or connect to a data source.

Upvotes: 4

HHH
HHH

Reputation: 37

RowSet interface, the rows are retrieved from a JDBC data source, but a rowset may be customized so that its data can also be from a spreadsheet, a flat file, or any other data source with a tabular format.

Disconnected (not connected to the data source except when reading data from it or writing data to it)

CachedRowSet

JoinRowSet

FilteredRowSet

WebRowSet

Cached Rowset - being disconnected and able to operate without a driver, is designed to work especially well with a thin client for passing data in a distributed application or for making a result set scrollable and updatable

WebRowSet - the ability to read and write a rowset in XML format.

FilteredRowSet- used to the filtered subset of data from a rowset.

JoinRowSet -used to combine data from two different RowSet objects. This can be especially valuable when related data is stored in different data sources

Documentation

Upvotes: 0

Related Questions