JdbcRowSet must implement.
ResultSet object that makes it possible
to use the result set as a JavaBeansTM
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.
JdbcRowSet ObjectJdbcRowSet 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:
PreparedStatement object and sets any of its
placeholder parameters
ResultSet object
execute method is successful, it will set the
appropriate private JdbcRowSet fields with the following:
Connection object -- the connection between the rowset
and the database
PreparedStatement object -- the query that produces
the result set
ResultSet object -- the result set that the rowset's
command produced and that is being made, in effect, a JavaBeans
component
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.
RowSet object.RowSet object's command.
In general, parameter values remain in force for repeated use of a
RowSet object. Setting a parameter value automatically clears its
previous value. However, in some cases it is useful to immediately
release the resources used by the current parameter values, which can
be done by calling the method clearParameters.
JdbcRowSet contains a Connection object from
the ResultSet or JDBC properties passed to it's constructors.
This method wraps the Connection commit method to allow flexible
auto commit or non auto commit transactional control support.
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.
RowSet object with data.
The execute method may use the following properties
to create a connection for reading data: url, data source name,
user name, password, transaction isolation, and type map.
The execute method may use the following properties
to create a statement to execute a command:
command, read only, maximum field size,
maximum rows, escape processing, and query timeout.
If the required properties have not been set, an exception is thrown. If this method is successful, the current contents of the rowset are discarded and the rowset's metadata is also (re)set. If there are outstanding updates, they are ignored.
If this RowSet object does not maintain a continuous connection
with its source of data, it may use a reader (a RowSetReader
object) to fill itself with data. In this case, a reader will have been
registered with this RowSet object, and the method
execute will call on the reader's readData
method as part of its implementation.
JdbcRowSet contains a Connection object from
the original ResultSet or JDBC properties passed to it. This
method wraps the Connection's getAutoCommit method
to allow an application to determine the JdbcRowSet transaction
behavior.
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.
RowSet object's command property.
The command property contains a command string, which must be an SQL
query, that can be executed to fill the rowset with data.
The default value is null.RowSet object. Users should set
either the url property or the data source name property. The rowset will use
the property that was set more recently to get a connection.RowSet object.
If escape scanning is enabled, which is the default, the driver will do
escape substitution before sending an SQL statement to the database.RowSet object with the method
setMatchColumn(int[] columnIdxes).RowSet object with the method
setMatchColumn(String [] columnNames).BINARY,
VARBINARY, LONGVARBINARYBINARY, CHAR,
VARCHAR, and LONGVARCHAR columns.
If the limit is exceeded, the excess data is silently discarded.RowSet
object can contain.
If the limit is exceeded, the excess rows are silently dropped.execute. It is not usually part of the serialized state
of a RowSet object.SQLException is thrown.JdbcRowSet
object.
If a second warning was reported on this JdbcRowSet object,
it will be chained to the first warning and can be retrieved by
calling the method RowSetWarning.getNextWarning on the
first warning. Subsequent warnings on this JdbcRowSet
object will be chained to the RowSetWarning objects
returned by the method RowSetWarning.getNextWarning.
The warning chain is automatically cleared each time a new row is read.
This method may not be called on a RowSet object
that has been closed;
doing so will cause an SQLException to be thrown.
Because it is always connected to its data source, a JdbcRowSet
object can rely on the presence of active
Statement, Connection, and ResultSet
instances. This means that applications can obtain additional
SQLWarning
notifications by calling the getNextWarning methods that
they provide.
Disconnected Rowset objects, such as a
CachedRowSet object, do not have access to
these getNextWarning methods.
boolean indicating whether rows marked
for deletion appear in the set of current rows. If true is
returned, deleted rows are visible with the current rows. If
false is returned, rows are not visible with the set of
current rows. The default value is false.
Standard rowset implementations may choose to restrict this behavior for security considerations or for certain deployment scenarios. The visibility of deleted rows is implementation-defined and does not represent standard behavior.
Note: Allowing deleted rows to remain visible complicates the behavior
of some standard JDBC RowSet implementations methods.
However, most rowset users can simply ignore this extra detail because
only very specialized applications will likely want to take advantage of
this feature.
RowSet object.Map object associated with this
RowSet object, which specifies the custom mapping
of SQL user-defined types, if any. The default is for the
type map to be empty.RowSet object will use to
create a connection if it uses the DriverManager
instead of a DataSource object to establish the connection.
The default value is null.RowSet object.
The username property is set at run time before calling the method
execute. It is
not usually part of the serialized state of a RowSet object.RowSet object is read-only.
If updates are possible, the default is for a rowset to be
updatable.
Attempts to update a read-only rowset will result in an
SQLException being thrown.
RowSet object.JdbcRowSet contains a Connection object from
the original ResultSet or JDBC properties passed to it.
Undoes all changes made in the current transaction and releases any
database locks currently held by this Connection object. This method
should be used only when auto-commit mode has been disabled.JdbcRowSet contains a Connection object from
the original ResultSet or JDBC properties passed to it.
Undoes all changes made in the current transaction to the last set savepoint
and releases any database locks currently held by this Connection
object. This method should be used only when auto-commit mode has been disabled.RowSet object's command
with the given Array value. The driver will convert this
to the ARRAY value that the Array object
represents before sending it to the database.RowSet object's command
to the given java.io.InputStream value.
It may be more practical to send a very large ASCII value via a
java.io.InputStream rather than as a LONGVARCHAR
parameter. The driver will read the data from the stream
as needed until it reaches end-of-file.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
JdbcRowSet contains a Connection object from
the original ResultSet or JDBC properties passed to it. This
method wraps the Connection's getAutoCommit method
to allow an application to set the JdbcRowSet transaction behavior.
Sets the current auto-commit mode for this Connection object.
RowSet object's command
to the given java.math.BigDeciaml value.
The driver converts this to
an SQL NUMERIC value before sending it to the database.RowSet object's command
to the given java.io.InputStream value.
It may be more practical to send a very large binary value via a
java.io.InputStream rather than as a LONGVARBINARY
parameter. The driver will read the data from the stream
as needed until it reaches end-of-file.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
RowSet object's command
with the given Blob value. The driver will convert this
to the BLOB value that the Blob object
represents before sending it to the database.RowSet object's command
to the given Java boolean value. The driver converts this to
an SQL BIT value before sending it to the database.RowSet object's command
to the given Java byte value. The driver converts this to
an SQL TINYINT value before sending it to the database.RowSet object's command
to the given Java array of byte values. Before sending it to the
database, the driver converts this to an SQL VARBINARY or
LONGVARBINARY value, depending on the argument's size relative
to the driver's limits on VARBINARY values.RowSet object's command
to the given java.io.Reader value.
It may be more practical to send a very large UNICODE value via a
java.io.Reader rather than as a LONGVARCHAR
parameter. The driver will read the data from the stream
as needed until it reaches end-of-file.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
RowSet object's command
with the given Clob value. The driver will convert this
to the CLOB value that the Clob object
represents before sending it to the database.RowSet object's command property to the given
SQL query.
This property is optional
when a rowset gets its data from a data source that does not support
commands, such as a spreadsheet.RowSet object to the given
concurrency level. This method is used to change the concurrency level
of a rowset, which is by default ResultSet.CONCUR_READ_ONLYRowSet object to the
given String.
The value of the data source name property can be used to do a lookup of
a DataSource object that has been registered with a naming
service. After being retrieved, the DataSource object can be
used to create a connection to the data source that it represents.
RowSet object's command
to the given java.sql.Date value. The driver converts this to
an SQL DATE value before sending it to the database, using the
default java.util.Calendar to calculate the date.RowSet object's command
with the given java.sql.Date value. The driver will convert this
to an SQL DATE value, using the given java.util.Calendar
object to calculate the date.RowSet object's command
to the given Java double value. The driver converts this to
an SQL DOUBLE value before sending it to the database.RowSet object on or
off. If escape scanning is on (the default), the driver will do
escape substitution before sending an SQL statement to the database.RowSet object's command
to the given Java float value. The driver converts this to
an SQL REAL value before sending it to the database.RowSet object's command
to the given Java int value. The driver converts this to
an SQL INTEGER value before sending it to the database.RowSet object's command
to the given Java long value. The driver converts this to
an SQL BIGINT value before sending it to the database.RowSet
object. A JoinRowSet object can now add this RowSet
object based on the match column.
Sub-interfaces such as the CachedRowSetTM
interface define the method CachedRowSet.setKeyColumns, which allows
primary key semantics to be enforced on specific columns.
Implementations of the setMatchColumn(int columnIdx) method
should ensure that the constraints on the key columns are maintained when
a CachedRowSet object sets a primary key column as a match column.
RowSet
object. A JoinRowSet object can now add this RowSet
object based on the match column.RowSet
object. A JoinRowSet object can now add this RowSet
object based on the match column.
Subinterfaces such as the CachedRowSet interface define
the method CachedRowSet.setKeyColumns, which allows
primary key semantics to be enforced on specific columns.
Implementations of the setMatchColumn(String columnIdx) method
should ensure that the constraints on the key columns are maintained when
a CachedRowSet object sets a primary key column as a match column.
RowSet
object. A JoinRowSet object can now add this RowSet
object based on the match column.BINARY,
VARBINARY, LONGVARBINARYBINARY, CHAR,
VARCHAR, and LONGVARCHAR columns.
If the limit is exceeded, the excess data is silently discarded.
For maximum portability, use values greater than 256.RowSet
object can contain to the specified number.
If the limit is exceeded, the excess rows are silently dropped.RowSet object's SQL
command to SQL NULL.
Note: You must specify the parameter's SQL type.
RowSet object's SQL
command to SQL NULL. This version of the method setNull
should be used for SQL user-defined types (UDTs) and REF type
parameters. Examples of UDTs include: STRUCT, DISTINCT,
JAVA_OBJECT, and named array types.
Note: To be portable, applications must give the
SQL type code and the fully qualified SQL type name when specifying
a NULL UDT or REF parameter. In the case of a UDT,
the name is the type name of the parameter itself. For a REF
parameter, the name is the type name of the referenced type. If
a JDBC driver does not need the type code or type name information,
it may ignore it.
Although it is intended for UDT and REF parameters,
this method may be used to set a null parameter of any JDBC type.
If the parameter does not have a user-defined or REF type,
the typeName parameter is ignored.
RowSet object's command
with a Java Object. For integral values, the
java.lang equivalent objects should be used.
The JDBC specification provides a standard mapping from Java Object types to SQL types. The driver will convert the given Java object to its standard SQL mapping before sending it to the database.
Note that this method may be used to pass datatabase-specific
abstract data types by using a driver-specific Java type.
If the object is of a class implementing SQLData,
the rowset should call the method SQLData.writeSQL
to write the object to an SQLOutput data stream.
If the object is an instance of a class implementing the Ref,
Struct, Array, Blob,
or Clob interfaces,
the driver uses the default mapping to the corresponding SQL type.
An exception is thrown if there is an ambiguity, for example, if the object is of a class implementing more than one of these interfaces.
RowSet object's command
with a Java Object. For integral values, the
java.lang equivalent objects should be used.
This method is like setObject above, but the scale used is the scale
of the second parameter. Scalar values have a scale of zero. Literal
values have the scale present in the literal.
Even though it is supported, it is not recommended that this method be called with floating point input values.
RowSet object's command
with the given Java Object. For integral values, the
java.lang equivalent objects should be used (for example,
an instance of the class Integer for an int).
The given Java object will be converted to the targetSqlType before being sent to the database.
If the object is of a class implementing SQLData,
the rowset should call the method SQLData.writeSQL
to write the object to an SQLOutput data stream.
If the object is an instance of a class implementing the Ref,
Struct, Array, Blob,
or Clob interfaces,
the driver uses the default mapping to the corresponding SQL type.
Note that this method may be used to pass datatabase-specific abstract data types.
RowSet object to
the given String.SQLException is thrown.RowSet object is read-only to the
given boolean.RowSet object's command
with the given Ref value. The driver will convert this
to the appropriate REF(<structured-type>) value.RowSet object's command
to the given Java short value. The driver converts this to
an SQL SMALLINT value before sending it to the database.showDeleted to the given
boolean value. This property determines whether
rows marked for deletion continue to appear in the set of current rows.
If the value is set to true, deleted rows are immediately
visible with the set of current rows. If the value is set to
false, the deleted rows are set as invisible with the
current set of rows.
Standard rowset implementations may choose to restrict this behavior for security considerations or for certain deployment scenarios. This is left as implementation-defined and does not represent standard behavior.
RowSet object's command
to the given Java String value. Before sending it to the
database, the driver converts this to an SQL VARCHAR or
LONGVARCHAR value, depending on the argument's size relative
to the driver's limits on VARCHAR values.RowSet object's command
to the given java.sql.Time value. The driver converts this to
an SQL TIME value before sending it to the database, using the
default java.util.Calendar to calculate it.RowSet object's command
with the given java.sql.Time value. The driver will convert this
to an SQL TIME value, using the given java.util.Calendar
object to calculate it, before sending it to the database.RowSet object's command
to the given java.sql.Timestamp value. The driver converts this to
an SQL TIMESTAMP value before sending it to the database, using the
default java.util.Calendar to calculate it.RowSet object's command
with the given java.sql.Timestamp value. The driver will
convert this to an SQL TIMESTAMP value, using the given
java.util.Calendar object to calculate it, before sending it to the
database.RowSet obejct.RowSet object to the given type.
This method is used to change the type of a rowset, which is by
default read-only and non-scrollable.java.util.Map object as the default
type map for this RowSet object. This type map will be
used unless another type map is supplied as a method parameter.RowSet object will use when it uses the
DriverManager to create a connection.
Setting this property is optional. If a URL is used, a JDBC driver
that accepts the URL must be loaded by the application before the
rowset is used to connect to a database. The rowset will use the URL
internally to create a database connection when reading or writing
data. Either a URL or a data source name is used to create a
connection, whichever was specified most recently.RowSet object to the
given String.RowSet
object.
RowSet objects that implement the Joinable interface
must ensure that a key-like constraint continues to be enforced until the
method CachedRowSet.unsetKeyColumns has been called on the
designated column.
RowSet
object.RowSet
object.
RowSet objects that implement the Joinable interface
must ensure that a key-like constraint continues to be enforced until the
method CachedRowSet.unsetKeyColumns has been called on the
designated column.
RowSet
object.