Learn JdbcRowSet, CachedRowSet and WebRowSet using Oracle

Just as DataSource objects provide an alternative to DriverManager, RowSet objects provide an alternative to ResultSet objects. The RowSet interface extends the ResultSet interface, giving you the same functionality for viewing and manipulating data plus extra functionality that makes it a flexible and powerful object to use in your applications.

A RowSet object enables you to use data retrieved from a data source in many different ways. For example, using rowsets, you can perform the following tasks:

  • Pass populated RowSet objects over networks to thin clients like PDAs
  • View and update data in disconnected environments
  • Mimic scrollable and updateable result sets for drivers that do not support these features
  • Generate self-contained XML documents representing RowSet objects

RowSet Modes:
Rowsets operate in two modes: connected and disconnected.

1) Connected RowSet: A connected rowset, like a result set, requires a continuous connection to the database. An error occurs if you use either a ResultSet or RowSet object after explicitly closing the connection or it otherwise breaks unexpectedly. In addition, a connected rowset always requires the presence of a JDBC driver so it can communicate with the database.

2) Disconnected RowSet: A disconnected rowset, by contrast, stores row and column data in memory. As a result, the object does not rely on a data source connection to view and manipulate the data; it just accesses it from memory. However, you do need a connection to initially populate a disconnected RowSet object. Once populated, the object disconnects from the data source automatically.

RowSet Types:

1) JdbcRowSet: The JdbcRowSet class provides a basic implementation of the javax.sql.RowSet interface, which turns a ResultSet object into a JavaBean and abstracts the details of working with ResultSet objects. You can use this object to simplify connection steps or to provide scrollable and updateable cursors for drivers that do not support these features. However, JdbcRowSet objects can only operate in connected mode, thus requiring the presence of a JDBC driver.

2) Cached RowSet: The CachedRowSet class provides the same functionality as the JdbcRowSet class, with one important difference: a CachedRowSet object can operate in a disconnected environment. As a result, it can function without a JDBC driver present. Once you populate a CachedRowSet object with data you may send it over the network to thin clients, provide it to sales professionals on their laptops, or serialize it for data archiving. The advantage of the CachedRowSet object is that the client to whom you send the object does not need the JDBC driver.

3) Web RowSet:The WebRowSet class extends the CachedRowSet class, which lets you use the same properties and methods as well as operate in disconnected mode. However, the WebRowSet object can generate XML documents representing itself. You can use these documents to create copies of the WebRowSet object, which makes it easy for you to distribute the information across the Web and through firewalls using HTTP. It will likely play a major role as the Web-services architecture continues to develop.

RowSet Comparision:

Following code demonstrate how to implement JdbcRowSet using Oracle

CacheRowSet implementation using Oracle…

and Finally WebRowSet…

About the Author

has written 68 posts.

I Love Coding, Analyzing, Designing and doing it the right way. I am obsessed about learn anything new daily and sharing what I have learn each Day. This Blog is journey of my Zeal, going through step by step to the mountain of desire to become prefect. Google Wanna Hire me ?

Copyright © 2017 TechZoo - Technology Blog. All rights reserved.
Proudly powered by WordPress. Developed by 7Tech Solutions