A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.oracle.com/javase/7/docs/api/javax/sql/rowset/JdbcRowSet.html below:

JdbcRowSet (Java Platform SE 7 )

The standard interface that all standard implementations of

JdbcRowSet

must implement.

1.0 Overview

A wrapper around a

ResultSet

object that makes it possible to use the result set as a JavaBeans

TM

component. Thus, 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 technology-enabled driver, it also effectively makes the driver a JavaBeans component.

Because it 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 and/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.

2.0 Creating a JdbcRowSet Object

The reference implementation of the

JdbcRowSet

interface,

JdbcRowSetImpl

, provides an implementation of the default constructor. A new instance is initialized with default values, which can be set with new values as needed. A new instance is not really functional until its

execute

method is called. In general, this method does the following:

If the

execute

method is successful, it will set the appropriate private

JdbcRowSet

fields with the following:

If these fields have not been set, meaning that the

execute

method has not executed successfully, no methods other than

execute

and

close

may be called on the rowset. All other public methods will throw an exception.

Before calling the execute method, however, the command and properties needed for establishing a connection must be set. The following code fragment creates a JdbcRowSetImpl object, sets the command and connection properties, sets the placeholder parameter, and then invokes the method execute.

     JdbcRowSetImpl jrs = new JdbcRowSetImpl();
     jrs.setCommand("SELECT * FROM TITLES WHERE TYPE = ?");
     jrs.setURL("jdbc:myDriver:myAttribute");
     jrs.setUsername("cervantes");
     jrs.setPassword("sancho");
     jrs.setString(1, "BIOGRAPHY");
     jrs.execute();
 

The variable

jrs

now represents an instance of

JdbcRowSetImpl

that is a thin wrapper around the

ResultSet

object containing all the rows in the table

TITLES

where the type of book is biography. At this point, operations called on

jrs

will affect the rows in the result set, which is effectively a JavaBeans component.

The implementation of the RowSet method execute in the JdbcRowSet reference implementation differs from that in the CachedRowSetTM reference implementation to account for the different requirements of connected and disconnected RowSet objects.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4