JdbcRowSet (javax.sql.JdbcRowSet interface) is a connected rowset that serves mainly as a thin wrapper around a ResultSet object to make a JDBC driver look like a JavaBeans component. According to J2SE 5.0 documentation, “a JdbcRowSet object can be one of the Beans that a tool makes available for composing an application. Because a JdbcRowSet is a connected rowset, that is, it continually maintains its connection to a database using a JDBC technologyenabled driver, it also effectively makes the driver a JavaBeans component.” JdbcRowSet is defined as follows:
Because JdbcRowSet is always connected to its database, an instance of JdbcRowSet can simply take calls invoked on it and in turn call them on its ResultSet object. As a consequence, a result set can, for example, be a component in a Swing application. Another advantage of a JdbcRowSet object is that it can be used to make a ResultSet object scrollable and updatable. All RowSet objects are by default scrollable and updatable. If the driver and database being used do not support scrolling or updating of result sets, an application can populate a JdbcRowSet object with the data of a ResultSet object and then operate on the JdbcRowSet object as if it were the ResultSet object.
The following code fragment illustrates creating a JdbcRowSet object, setting its properties, and executing the command string in its command property:
At this point, jrs contains all of the selected data in the books table. After creating a JdbcRowSet object, you may use ResultSet methods because it is effectively operating on a ResultSet object. It can navigate the rows in jrs, retrieve column values, update column values, insert new rows, and so on. For example, to process results, you may write the following to iterate all rows:
In this example, the next three lines of code go to the fifth row and retrieve the value in the first and second columns using ResultSet methods:
Once you create a JdbcRowSet object, then you can extract its metadata by using this code (note that the method getMetaData() is a ResultSet method that returns a ResultSetMetaData object, so it must be cast to a RowSetMetaData object before it can be assigned to rsMetaData):
For rowset objects, you may pass input parameters (similar to PreparedStatement objects). The following code fragment shows what an application might do: it sets the rowset’s command, sets the command’s parameters, and executes the command. Simply by calling the execute method, jrs populates itself with the requested data from the table CUSTOMERS:
Sun’s reference implementation class, com.sun.rowset.JdbcRowSetImpl, which is defined next, has four constructors. In order to understand the JdbcRowSetImpl class, we need to understand the BaseRowSet class—the superclass for the JdbcRowSetImpl class.
BaseRowSet Class Definition
According to the JDBC 3.0 Specification (implemented in JDK 1.5), the BaseRowSet is an abstract class providing a RowSet object with its basic functionality. The basic functions include having properties and sending event notifications, which all JavaBeans components must implement. The BaseRowSet class provides the core functionality for all RowSet implementations, and all standard implementations may use this class in combination with one or more RowSet interfaces in order to provide a standard vendor-specific implementation. To clarify, all implementations must implement at least one of the RowSet interfaces (JdbcRowSet, CachedRowSet, JoinRowSet, FilteredRowSet, or WebRowSet). This means that any implementation that extends the BaseRowSet class must also implement one of the RowSet interfaces.
The BaseRowSet class provides the following:
JdbcRowSetImpl Class Definition
Here, the javax.sql.rowset.Joinable interface provides the methods for getting and setting a match column, which is the basis for forming the SQL JOIN formed by adding RowSet objects to a JoinRowSet object.
JdbcRowSetImpl Class Constructors
JDBC Related Interview Questions
|Core Java Interview Questions||JSP Interview Questions|
|Java Servlets Interview Questions||EJB(Enterprise JavaBeans) Interview Questions|
|JSTL(JSP Standard Tag Library) Interview Questions||JNDI (Java Naming and Directory Interface) Interview Questions|
|Java Bean Utils Interview Questions||AWT (Abstract Window Toolkit) Interview Questions|
What Is Jdbc Programming?
Database Metadata, Part 1
Database Metadata, Part 2
Exploring Driver Property Information
Rowset Metadata A
Web Access To Metadata,part 1
Web Access To Metadata, Part 2
Rdf And Jdbc Metadata
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.