BaseRowSetpublic abstract class BaseRowSet extends Object implements Serializable, CloneableAn abstract class providing a RowSet object with its basic functionality.
The basic functions include having properties and sending event notifications,
which all JavaBeansTM components must implement.
1.0 Overview
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:
- Properties
- Fields for storing current properties
- Methods for getting and setting properties
- Event notification
- A complete set of setter methods for setting the parameters in a
RowSet object's command
- Streams
- Fields for storing stream instances
- Constants for indicating the type of a stream
2.0 Setting Properties
All rowsets maintain a set of properties, which will usually be set using
a tool. The number and kinds of properties a rowset has will vary,
depending on what the RowSet implementation does and how it gets
its data. For example,
rowsets that get their data from a ResultSet object need to
set the properties that are required for making a database connection.
If a RowSet object uses the DriverManager facility to make a
connection, it needs to set a property for the JDBC URL that identifies the
appropriate driver, and it needs to set the properties that give the
user name and password.
If, on the other hand, the rowset uses a DataSource object
to make the connection, which is the preferred method, it does not need to
set the property for the JDBC URL. Instead, it needs to set the property
for the logical name of the data source along with the properties for
the user name and password.
NOTE: In order to use a DataSource object for making a
connection, the DataSource object must have been registered
with a naming service that uses the Java Naming and Directory
InterfaceTM (JNDI) API. This registration
is usually done by a person acting in the capacity of a system administrator.
3.0 Setting the Command and Its Parameters
When a rowset gets its data from a relational database, it executes a command (a query)
that produces a ResultSet object. This query is the command that is set
for the RowSet object's command property. The rowset populates itself with data by reading the
data from the ResultSet object into itself. If the query
contains placeholders for values to be set, the BaseRowSet setter methods
are used to set these values. All setter methods allow these values to be set
to null if required.
The following code fragment illustrates how the
CachedRowSet TM
object crs might have its command property set. Note that if a
tool is used to set properties, this is the code that the tool would use.
crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
"WHERE CREDIT_LIMIT > ? AND REGION = ?");
In this example, the values for CREDIT_LIMIT and
REGION are placeholder parameters, which are indicated with a
question mark (?). The first question mark is placeholder parameter number
1 , the second question mark is placeholder parameter number
2 , and so on. Any placeholder parameters must be set with
values before the query can be executed. To set these
placeholder parameters, the BaseRowSet class provides a set of setter
methods, similar to those provided by the PreparedStatement
interface, for setting values of each data type. A RowSet object stores the
parameter values internally, and its execute method uses them internally
to set values for the placeholder parameters
before it sends the command to the DBMS to be executed.
The following code fragment demonstrates
setting the two parameters in the query from the previous example.
crs.setInt(1, 5000);
crs.setString(2, "West");
If the execute method is called at this point, the query
sent to the DBMS will be:
"SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
"WHERE CREDIT_LIMIT > 5000 AND REGION = 'West'"
NOTE: Setting Array , Clob , Blob and
Ref objects as a command parameter, stores these values as
SerialArray , SerialClob , SerialBlob
and SerialRef objects respectively.
4.0 Handling of Parameters Behind the Scenes
NOTE: The BaseRowSet class provides two kinds of setter methods,
those that set properties and those that set placeholder parameters. The setter
methods discussed in this section are those that set placeholder parameters.
The placeholder parameters set with the BaseRowSet setter methods
are stored as objects in an internal Hashtable object.
Primitives are stored as their Object type. For example, byte
is stored as Byte object, and int is stored as
an Integer object.
When the method execute is called, the values in the
Hashtable object are substituted for the appropriate placeholder
parameters in the command.
A call to the method getParams returns the values stored in the
Hashtable object as an array of Object instances.
An element in this array may be a simple Object instance or an
array (which is a type of Object ). The particular setter method used
determines whether an element in this array is an Object or an array.
The majority of methods for setting placeholder parameters take two parameters,
with the first parameter
indicating which placeholder parameter is to be set, and the second parameter
giving the value to be set. Methods such as getInt ,
getString , getBoolean , and getLong fall into
this category. After these methods have been called, a call to the method
getParams will return an array with the values that have been set. Each
element in the array is an Object instance representing the
values that have been set. The order of these values in the array is determined by the
int (the first parameter) passed to the setter method. The values in the
array are the values (the second parameter) passed to the setter method.
In other words, the first element in the array is the value
to be set for the first placeholder parameter in the RowSet object's
command. The second element is the value to
be set for the second placeholder parameter, and so on.
Several setter methods send the driver and DBMS information beyond the value to be set.
When the method getParams is called after one of these setter methods has
been used, the elements in the array will themselves be arrays to accommodate the
additional information. In this category, the method setNull is a special case
because one version takes only
two parameters (setNull(int parameterIndex, int SqlType) ). Nevertheless,
it requires
an array to contain the information that will be passed to the driver and DBMS. The first
element in this array is the value to be set, which is null , and the
second element is the int supplied for sqlType, which
indicates the type of SQL value that is being set to null . This information
is needed by some DBMSs and is therefore required in order to ensure that applications
are portable.
The other version is intended to be used when the value to be set to null
is a user-defined type. It takes three parameters
(setNull(int parameterIndex, int sqlType, String typeName) ) and also
requires an array to contain the information to be passed to the driver and DBMS.
The first two elements in this array are the same as for the first version of
setNull . The third element, typeName, gives the SQL name of
the user-defined type. As is true with the other setter methods, the number of the
placeholder parameter to be set is indicated by an element's position in the array
returned by getParams . So, for example, if the parameter
supplied to setNull is 2 , the second element in the array
returned by getParams will be an array of two or three elements.
Some methods, such as setObject and setDate have versions
that take more than two parameters, with the extra parameters giving information
to the driver or the DBMS. For example, the methods setDate ,
setTime , and setTimestamp can take a Calendar
object as their third parameter. If the DBMS does not store time zone information,
the drivern uses the Calendar object to construct the Date ,
Time , or Timestamp object being set. As is true with other
methods that provide additional information, the element in the array returned
by getParams is an array instead of a simple Object instance.
The methods setAsciiStream , setBinaryStream ,
setCharacterStream , and setUnicodeStream (which is
deprecated, so applications should use getCharacterStream instead)
take three parameters, so for them, the element in the array returned by
getParams is also an array. What is different about these setter
methods is that in addition to the information provided by parameters, the array contains
one of the BaseRowSet constants indicating the type of stream being set.
NOTE: The method getParams is called internally by
RowSet implementations extending this class; it is not normally called by an
application programmer directly.
5.0 Event Notification
The BaseRowSet class provides the event notification
mechanism for rowsets. It contains the field
listeners , methods for adding and removing listeners, and
methods for notifying listeners of changes.
A listener is an object that has implemented the RowSetListener interface.
If it has been added to a RowSet object's list of listeners, it will be notified
when an event occurs on that RowSet object. Each listener's
implementation of the RowSetListener methods defines what that object
will do when it is notified that an event has occurred.
There are three possible events for a RowSet object:
- the cursor moves
- an individual row is changed (updated, deleted, or inserted)
- the contents of the entire
RowSet object are changed
The BaseRowSet method used for the notification indicates the
type of event that has occurred. For example, the method
notifyRowChanged indicates that a row has been updated,
deleted, or inserted. Each of the notification methods creates a
RowSetEvent object, which is supplied to the listener in order to
identify the RowSet object on which the event occurred.
What the listener does with this information, which may be nothing, depends on how it was
implemented.
6.0 Default Behavior
A default BaseRowSet object is initialized with many starting values.
The following is true of a default RowSet instance that extends
the BaseRowSet class:
- Has a scrollable cursor and does not show changes
made by others.
- Is updatable.
- Does not show rows that have been deleted.
- Has no time limit for how long a driver may take to
execute the
RowSet object's command.
- Has no limit for the number of rows it may contain.
- Has no limit for the number of bytes a column may contain. NOTE: This
limit applies only to columns that hold values of the
following types:
BINARY , VARBINARY ,
LONGVARBINARY , CHAR , VARCHAR ,
and LONGVARCHAR .
- Will not see uncommitted data (make "dirty" reads).
- Has escape processing turned on.
- Has its connection's type map set to
null .
- Has an empty
Vector object for storing the values set
for the placeholder parameters in the RowSet object's command.
If other values are desired, an application must set the property values
explicitly. For example, the following line of code sets the maximum number
of rows for the CachedRowSet object crs to 500.
crs.setMaxRows(500);
Methods implemented in extensions of this BaseRowSet class must throw an
SQLException object for any violation of the defined assertions. Also, if the
extending class overrides and reimplements any BaseRowSet method and encounters
connectivity or underlying data source issues, that method may in addition throw an
SQLException object for that reason. |
Fields Summary |
---|
public static final int | UNICODE_STREAM_PARAMA constant indicating to a RowSetReaderImpl object
that a given parameter is a Unicode stream. This
RowSetReaderImpl object is provided as an extension of the
SyncProvider abstract class defined in the
SyncFactory static factory SPI mechanism. | public static final int | BINARY_STREAM_PARAMA constant indicating to a RowSetReaderImpl object
that a given parameter is a binary stream. A
RowSetReaderImpl object is provided as an extension of the
SyncProvider abstract class defined in the
SyncFactory static factory SPI mechanism. | public static final int | ASCII_STREAM_PARAMA constant indicating to a RowSetReaderImpl object
that a given parameter is an ASCII stream. A
RowSetReaderImpl object is provided as an extension of the
SyncProvider abstract class defined in the
SyncFactory static factory SPI mechanism. | protected InputStream | binaryStreamThe InputStream object that will be
returned by the method getBinaryStream , which is
specified in the ResultSet interface. | protected InputStream | unicodeStreamThe InputStream object that will be
returned by the method getUnicodeStream ,
which is specified in the ResultSet interface. | protected InputStream | asciiStreamThe InputStream object that will be
returned by the method getAsciiStream ,
which is specified in the ResultSet interface. | protected Reader | charStreamThe Reader object that will be
returned by the method getCharacterStream ,
which is specified in the ResultSet interface. | private String | commandThe query that will be sent to the DBMS for execution when the
method execute is called. | private String | URLThe JDBC URL the reader, writer, or both supply to the method
DriverManager.getConnection when the
DriverManager is used to get a connection.
The JDBC URL identifies the driver to be used to make the conndection.
This URL can be found in the documentation supplied by the driver
vendor. | private String | dataSourceThe logical name of the data source that the reader/writer should use
in order to retrieve a DataSource object from a Java
Directory and Naming Interface (JNDI) naming service. | private transient String | usernameThe user name the reader, writer, or both supply to the method
DriverManager.getConnection when the
DriverManager is used to get a connection. | private transient String | passwordThe password the reader, writer, or both supply to the method
DriverManager.getConnection when the
DriverManager is used to get a connection. | private int | rowSetTypeA constant indicating the type of this JDBC RowSet
object. It must be one of the following ResultSet
constants: TYPE_FORWARD_ONLY ,
TYPE_SCROLL_INSENSITIVE , or
TYPE_SCROLL_SENSITIVE . | private boolean | showDeletedA boolean indicating whether deleted rows are visible in this
JDBC RowSet object . | private int | queryTimeoutThe maximum number of seconds the driver
will wait for a command to execute. This limit applies while
this JDBC RowSet object is connected to its data
source, that is, while it is populating itself with
data and while it is writing data back to the data source. | private int | maxRowsThe maximum number of rows the reader should read. | private int | maxFieldSizeThe maximum field size the reader should read. | private int | concurrencyA constant indicating the concurrency of this JDBC RowSet
object. It must be one of the following ResultSet
constants: CONCUR_READ_ONLY or
CONCUR_UPDATABLE . | private boolean | readOnlyA boolean indicating whether this JDBC RowSet
object is read-only. true indicates that it is read-only;
false that it is writable. | private boolean | escapeProcessingA boolean indicating whether the reader for this
JDBC RowSet object should perform escape processing.
true means that escape processing is turned on;
false that it is not. The default is true . | private int | isolationA constant indicating the isolation level of the connection
for this JDBC RowSet object . It must be one of
the following Connection constants:
TRANSACTION_NONE ,
TRANSACTION_READ_UNCOMMITTED ,
TRANSACTION_READ_COMMITTED ,
TRANSACTION_REPEATABLE_READ or
TRANSACTION_SERIALIZABLE . | private int | fetchDirA constant used as a hint to the driver that indicates the direction in
which data from this JDBC RowSet object is going
to be fetched. The following ResultSet constants are
possible values:
FETCH_FORWARD ,
FETCH_REVERSE ,
FETCH_UNKNOWN .
Unused at this time. | private int | fetchSizeA hint to the driver that indicates the expected number of rows
in this JDBC RowSet object .
Unused at this time. | private Map | mapThe java.util.Map object that contains entries mapping
SQL type names to classes in the Java programming language for the
custom mapping of user-defined types. | private Vector | listenersA Vector object that holds the list of listeners
that have registered with this RowSet object. | private Hashtable | paramsA Vector object that holds the parameters set
for this RowSet object's current command. | static final long | serialVersionUID |
Constructors Summary |
---|
public BaseRowSet()Constructs a new BaseRowSet object initialized with
a default Vector object for its listeners
field. The other default values with which it is initialized are listed
in Section 6.0 of the class comment for this class. // could be transient?
// allocate the listeners collection
listeners = new Vector();
|
Methods Summary |
---|
public void | addRowSetListener(javax.sql.RowSetListener listener)The listener will be notified whenever an event occurs on this RowSet
object.
A listener might, for example, be a table or graph that needs to
be updated in order to accurately reflect the current state of
the RowSet object.
Note: if the RowSetListener object is
null , this method silently discards the null
value and does not add a null reference to the set of listeners.
Note: if the listener is already set, and the new RowSetListerner
instance is added to the set of listeners already registered to receive
event notifications from this RowSet .
listeners.add(listener);
| private void | checkParamIndex(int idx)Checks the given index to see whether it is less than 1 and
throws an SQLException object if it is.
This method is called by many methods internally; it is never
called by an application directly.
if ((idx < 1)) {
throw new SQLException("Invalid Parameter Index");
}
| private void | checkforRowSetInterface()Determine if instance of this class extends the RowSet interface.
if ((this instanceof javax.sql.RowSet) == false) {
throw new SQLException("The class extending abstract class BaseRowSet " +
"must implement javax.sql.RowSet or one of it's sub-interfaces.");
}
| public void | clearParameters()Clears all of the current parameter values in this RowSet
object's internal representation of the parameters to be set in
this RowSet object's command when it is executed.
In general, parameter values remain in force for repeated use in
this RowSet object's command. Setting a parameter value with the
setter methods automatically clears the value of the
designated parameter and replaces it with the new specified value.
This method is called internally by the setCommand
method to clear all of the parameters set for the previous command.
Furthermore, this method differs from the initParams
method in that it maintains the schema of the RowSet object.
params.clear();
| public java.lang.String | getCommand()Retrieves the SQL query that is the command for this
RowSet object. The command property contains the query that
will be executed to populate this RowSet object.
The SQL query returned by this method is used by RowSet methods
such as execute and populate , which may be implemented
by any class that extends the BaseRowSet abstract class and
implements one or more of the standard JSR-114 RowSet
interfaces.
The command is used by the RowSet object's
reader to obtain a ResultSet object. The reader then
reads the data from the ResultSet object and uses it to
to populate this RowSet object.
The default value for the command property is null .
return command;
| public int | getConcurrency()Returns the concurrency for this RowSet object.
The default is CONCUR_UPDATABLE for both connected and
disconnected RowSet objects.
An application can call the method setConcurrency at any time
to change a RowSet object's concurrency.
return concurrency;
| public java.lang.String | getDataSourceName()Returns the logical name that when supplied to a naming service
that uses the Java Naming and Directory Interface (JNDI) API, will
retrieve a javax.sql.DataSource object. This
DataSource object can be used to establish a connection
to the data source that it represents.
Users should set either the url or the data source name property.
The driver will use the property set most recently to establish a
connection.
return dataSource;
| public boolean | getEscapeProcessing()Ascertains whether escape processing is enabled for this
RowSet object.
return escapeProcessing;
| public int | getFetchDirection()Retrieves this RowSet object's current setting for the
fetch direction. The default type is ResultSet.FETCH_FORWARD
//Added the following code to throw a
//SQL Exception if the fetchDir is not
//set properly.Bug id:4914155
// This checking is not necessary!
/*
if((fetchDir != ResultSet.FETCH_FORWARD) &&
(fetchDir != ResultSet.FETCH_REVERSE) &&
(fetchDir != ResultSet.FETCH_UNKNOWN)) {
throw new SQLException("Fetch Direction Invalid");
}
*/
return (fetchDir);
| public int | getFetchSize()Returns the fetch size for this RowSet object. The default
value is zero.
return fetchSize;
| public int | getMaxFieldSize()Retrieves the maximum number of bytes that can be used for a column
value in this RowSet object.
This limit applies only to columns that hold values of the
following types: BINARY , VARBINARY ,
LONGVARBINARY , CHAR , VARCHAR ,
and LONGVARCHAR . If the limit is exceeded, the excess
data is silently discarded.
return maxFieldSize;
| public int | getMaxRows()Retrieves the maximum number of rows that this RowSet object may contain. If
this limit is exceeded, the excess rows are silently dropped.
return maxRows;
| public java.lang.Object[] | getParams()Retrieves an array containing the parameter values (both Objects and
primitives) that have been set for this
RowSet object's command and throws an SQLException object
if all parameters have not been set. Before the command is sent to the
DBMS to be executed, these parameters will be substituted
for placeholder parameters in the PreparedStatement object
that is the command for a RowSet implementation extending
the BaseRowSet class.
Each element in the array that is returned is an Object instance
that contains the values of the parameters supplied to a setter method.
The order of the elements is determined by the value supplied for
parameterIndex. If the setter method takes only the parameter index
and the value to be set (possibly null), the array element will contain the value to be set
(which will be expressed as an Object ). If there are additional
parameters, the array element will itself be an array containing the value to be set
plus any additional parameter values supplied to the setter method. If the method
sets a stream, the array element includes the type of stream being supplied to the
method. These additional parameters are for the use of the driver or the DBMS and may or
may not be used.
NOTE: Stored parameter values of types Array , Blob ,
Clob and Ref are returned as SerialArray ,
SerialBlob , SerialClob and SerialRef
respectively.
if (params == null) {
initParams();
Object [] paramsArray = new Object[params.size()];
return paramsArray;
} else {
// The parameters may be set in random order
// but all must be set, check to verify all
// have been set till the last parameter
// else throw exception.
Object[] paramsArray = new Object[params.size()];
for (int i = 0; i < params.size(); i++) {
paramsArray[i] = params.get(new Integer(i));
if (paramsArray[i] == null) {
throw new SQLException("missing parameter: " + (i + 1));
} //end if
} //end for
return paramsArray;
} //end if
| public java.lang.String | getPassword()Returns the password used to create a database connection for this
RowSet object. Because the password property is not
serialized, it is set at run time before calling the method
execute . The default value is null
return password;
| public int | getQueryTimeout()Retrieves the maximum number of seconds the driver will wait for a
query to execute. If the limit is exceeded, an SQLException
is thrown.
return queryTimeout;
| public boolean | getShowDeleted()Retrieves a boolean indicating whether rows marked
for deletion appear in the set of current rows.
The default value is false .
Note: Allowing deleted rows to remain visible complicates the behavior
of some of the methods. However, most RowSet object users
can simply ignore this extra detail because only sophisticated
applications will likely want to take advantage of this feature.
return showDeleted;
| public int | getTransactionIsolation()Returns the transaction isolation property for this
RowSet object's connection. This property represents
the transaction isolation level requested for use in transactions.
For RowSet implementations such as
the CachedRowSet that operate in a disconnected environment,
the SyncProvider object
offers complementary locking and data integrity options. The
options described below are pertinent only to connected RowSet
objects (JdbcRowSet objects).
return isolation;
| public int | getType()Returns the type of this RowSet object. The type is initially
determined by the statement that created the RowSet object.
The RowSet object can call the method
setType at any time to change its
type. The default is TYPE_SCROLL_INSENSITIVE .
return rowSetType;
| public java.util.Map | getTypeMap()Retrieves the type map associated with the Connection
object for this RowSet object.
Drivers that support the JDBC 3.0 API will create
Connection objects with an associated type map.
This type map, which is initially empty, can contain one or more
fully-qualified SQL names and Class objects indicating
the class to which the named SQL value will be mapped. The type mapping
specified in the connection's type map is used for custom type mapping
when no other type map supersedes it.
If a type map is explicitly supplied to a method that can perform
custom mapping, that type map supersedes the connection's type map.
return map;
| public java.lang.String | getUrl()Retrieves the JDBC URL that this RowSet object's
javax.sql.Reader object uses to make a connection
with a relational database using a JDBC technology-enabled driver.
The Url property will be null if the underlying data
source is a non-SQL data source, such as a spreadsheet or an XML
data source.
return URL;
| public java.lang.String | getUsername()Returns the user name used to create a database connection. Because it
is not serialized, the username property is set at runtime before
calling the method execute .
return username;
| protected void | initParams()Performs the necessary internal configurations and initializations
to allow any JDBC RowSet implementation to start using
the standard facilities provided by a BaseRowSet
instance. This method should be called after the RowSet object
has been instantiated to correctly initialize all parameters. This method
should never be called by an application, but is called from with
a RowSet implementation extending this class.
params = new Hashtable();
| public boolean | isReadOnly()Returns a boolean indicating whether this
RowSet object is read-only.
Any attempts to update a read-only RowSet object will result in an
SQLException being thrown. By default,
rowsets are updatable if updates are possible.
return readOnly;
| protected void | notifyCursorMoved()Notifies all of the listeners registered with this
RowSet object that its cursor has moved.
When an application calls a method to move the cursor,
that method moves the cursor and then calls this method
internally. An application should never invoke
this method directly.
checkforRowSetInterface();
if (listeners.isEmpty() == false) {
RowSetEvent event = new RowSetEvent((RowSet)this);
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
((RowSetListener)i.next()).cursorMoved(event);
}
}
| protected void | notifyRowChanged()Notifies all of the listeners registered with this RowSet object that
one of its rows has changed.
When an application calls a method that changes a row, such as
the CachedRowSet methods insertRow ,
updateRow , or deleteRow ,
that method calls notifyRowChanged
internally. An application should never invoke
this method directly.
checkforRowSetInterface();
if (listeners.isEmpty() == false) {
RowSetEvent event = new RowSetEvent((RowSet)this);
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
((RowSetListener)i.next()).rowChanged(event);
}
}
| protected void | notifyRowSetChanged()Notifies all of the listeners registered with this RowSet
object that its entire contents have changed.
When an application calls methods that change the entire contents
of the RowSet object, such as the CachedRowSet methods
execute , populate , restoreOriginal ,
or release , that method calls notifyRowSetChanged
internally (either directly or indirectly). An application should
never invoke this method directly.
checkforRowSetInterface();
if (listeners.isEmpty() == false) {
RowSetEvent event = new RowSetEvent((RowSet)this);
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
((RowSetListener)i.next()).rowSetChanged(event);
}
}
| public void | removeRowSetListener(javax.sql.RowSetListener listener)Removes the designated object from this RowSet object's list of listeners.
If the given argument is not a registered listener, this method
does nothing.
Note: if the RowSetListener object is
null , this method silently discards the null
value.
listeners.remove(listener);
| public void | setArray(int parameterIndex, java.sql.Array array)Sets the designated parameter to an Array object in the
Java programming language. The driver converts this to an SQL
ARRAY value when it sends it to the database. Internally,
the Array is represented as a SerialArray
to ensure serializability.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
Note: JdbcRowSet does not require the populate method
as it is undefined in this class.
After this method has been called, a call to the
method getParams
will return an object array of the current command parameters, which will
include the Array object set for placeholder parameter number
parameterIndex .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
checkParamIndex(parameterIndex);
if (params == null){
throw new SQLException("Set initParams() before setArray");
}
params.put(new Integer(parameterIndex - 1), new SerialArray(array));
| public void | setAsciiStream(int parameterIndex, java.io.InputStream x, int length)Sets the designated parameter to the given
java.io.InputStream object,
which will have the specified number of bytes.
The contents of the stream will be read and sent to the database.
This method throws an SQLException object if the number of bytes
read and sent to the database is not equal to length.
When a very large ASCII value is input to a LONGVARCHAR
parameter, it may be more practical to send it via a
java.io.InputStream object. A JDBC technology-enabled
driver will read the data from the stream as needed until it reaches
end-of-file. The driver will do any necessary conversion from ASCII to
the database CHAR format.
Note: This stream object can be either a standard
Java stream object or your own subclass that implements the
standard interface.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
Note: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after setAsciiStream
has been called will return an array containing the parameter values that
have been set. The element in the array that represents the values
set with this method will itself be an array. The first element of that array
is the given java.io.InputStream object.
The second element is the value set for length.
The third element is an internal BaseRowSet constant
specifying that the stream passed to this method is an ASCII stream.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the input stream being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
Object asciiStream[];
checkParamIndex(parameterIndex);
asciiStream = new Object[3];
asciiStream[0] = x;
asciiStream[1] = new Integer(length);
asciiStream[2] = new Integer(ASCII_STREAM_PARAM);
if(params == null){
throw new SQLException("Set initParams() before setAsciiStream");
}
params.put(new Integer(parameterIndex - 1), asciiStream);
| public void | setBigDecimal(int parameterIndex, java.math.BigDecimal x)Sets the designated parameter to the given
java.lang.BigDecimal value. The driver converts this to
an SQL NUMERIC value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
Note: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setBigDecimal");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setBinaryStream(int parameterIndex, java.io.InputStream x, int length)Sets the designated parameter to the given java.io.InputStream
object, which will have the specified number of bytes.
The contents of the stream will be read and sent to the database.
This method throws an SQLException object if the number of bytes
read and sent to the database is not equal to length.
When a very large binary value is input to a
LONGVARBINARY parameter, it may be more practical
to send it via a java.io.InputStream object.
A JDBC technology-enabled driver will read the data from the
stream as needed until it reaches end-of-file.
Note: This stream object can be either a standard
Java stream object or your own subclass that implements the
standard interface.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after setBinaryStream
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given java.io.InputStream object.
The second element is the value set for length.
The third element is an internal BaseRowSet constant
specifying that the stream passed to this method is a binary stream.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the input stream being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
Object binaryStream[];
checkParamIndex(parameterIndex);
binaryStream = new Object[3];
binaryStream[0] = x;
binaryStream[1] = new Integer(length);
binaryStream[2] = new Integer(BINARY_STREAM_PARAM);
if(params == null){
throw new SQLException("Set initParams() before setBinaryStream");
}
params.put(new Integer(parameterIndex - 1), binaryStream);
| public void | setBlob(int parameterIndex, java.sql.Blob x)Sets the designated parameter to the given Blob object in
the Java programming language. The driver converts this to an SQL
BLOB value when it sends it to the database. Internally,
the Blob is represented as a SerialBlob
to ensure serializability.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
After this method has been called, a call to the
method getParams
will return an object array of the current command parameters, which will
include the Blob object set for placeholder parameter number
parameterIndex .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setBlob");
}
params.put(new Integer(parameterIndex - 1), new SerialBlob(x));
| public void | setBoolean(int parameterIndex, boolean x)Sets the designated parameter to the given boolean in the
Java programming language. The driver converts this to an SQL
BIT value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute , populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setNull");
}
params.put(new Integer(parameterIndex - 1), new Boolean(x));
| public void | setByte(int parameterIndex, byte x)Sets the designated parameter to the given byte in the Java
programming language. The driver converts this to an SQL
TINYINT value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setByte");
}
params.put(new Integer(parameterIndex - 1), new Byte(x));
| public void | setBytes(int parameterIndex, byte[] x)Sets the designated parameter to the given array of bytes.
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) when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setBytes");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setCharacterStream(int parameterIndex, java.io.Reader reader, int length)Sets the designated parameter to the given java.io.Reader
object, which will have the specified number of characters. The
contents of the reader will be read and sent to the database.
This method throws an SQLException if the number of bytes
read and sent to the database is not equal to length.
When a very large Unicode value is input to a
LONGVARCHAR parameter, it may be more practical
to send it via a Reader object.
A JDBC technology-enabled driver will read the data from the
stream as needed until it reaches end-of-file.
The driver will do any necessary conversion from Unicode to the
database CHAR format.
The byte format of the Unicode stream must be Java UTF-8, as
defined in the Java Virtual Machine Specification.
Note: This stream object can be either a standard
Java stream object or your own subclass that implements the
standard interface.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after
setCharacterStream
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given java.io.Reader object.
The second element is the value set for length.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the reader being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
Object charStream[];
checkParamIndex(parameterIndex);
charStream = new Object[2];
charStream[0] = reader;
charStream[1] = new Integer(length);
if(params == null){
throw new SQLException("Set initParams() before setCharacterStream");
}
params.put(new Integer(parameterIndex - 1), charStream);
| public void | setClob(int parameterIndex, java.sql.Clob x)Sets the designated parameter to the given Clob object in
the Java programming language. The driver converts this to an SQL
CLOB value when it sends it to the database. Internally, the
Clob is represented as a SerialClob to ensure
serializability.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
After this method has been called, a call to the
method getParams
will return an object array of the current command parameters, which will
include the Clob object set for placeholder parameter number
parameterIndex .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setClob");
}
params.put(new Integer(parameterIndex - 1), new SerialClob(x));
| public void | setCommand(java.lang.String cmd)Sets this RowSet object's command property to
the given String object and clears the parameters, if any,
that were set for the previous command.
The command property may not be needed if the RowSet
object gets its data from a source that does not support commands,
such as a spreadsheet or other tabular file.
Thus, this property is optional and may be null .
// cmd equal to null or
// cmd with length 0 (implies url =="")
// are not independent events.
if(cmd == null) {
command = null;
} else if (cmd.length() == 0) {
throw new SQLException("Invalid command string detected. " +
"Cannot be of length less than 0");
} else {
// "unbind" any parameters from any previous command.
if(params == null){
throw new SQLException("Set initParams() before setCommand");
}
params.clear();
command = new String(cmd);
}
| public void | setConcurrency(int concurrency)Sets the concurrency for this RowSet object to
the specified concurrency. The default concurrency for any RowSet
object (connected or disconnected) is ResultSet.CONCUR_UPDATABLE ,
but this method may be called at any time to change the concurrency.
if((concurrency != ResultSet.CONCUR_READ_ONLY) &&
(concurrency != ResultSet.CONCUR_UPDATABLE)) {
throw new SQLException("Invalid concurrency set. Must be either " +
"ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE.");
}
this.concurrency = concurrency;
| public void | setDataSourceName(java.lang.String name)Sets the DataSource name property for this RowSet
object to the given logical name and sets this RowSet object's
Url property to null . The name must have been bound to a
DataSource object in a JNDI naming service so that an
application can do a lookup using that name to retrieve the
DataSource object bound to it. The DataSource
object can then be used to establish a connection to the data source it
represents.
Users should set either the Url property or the dataSourceName property.
If both properties are set, the driver will use the property set most recently.
if (name == null) {
dataSource = null;
} else if (name.equals("")) {
throw new SQLException("DataSource name cannot be empty string");
} else {
dataSource = new String(name);
}
URL = null;
| public void | setDate(int parameterIndex, java.sql.Date x)Sets the designated parameter to the given java.sql.Date
value. The driver converts this to an SQL
DATE value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version
of setDate
has been called will return an array with the value to be set for
placeholder parameter number parameterIndex being the Date
object supplied as the second parameter.
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setDate");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setDate(int parameterIndex, java.sql.Date x, java.util.Calendar cal)Sets the designated parameter to the given java.sql.Date
object.
When the DBMS does not store time zone information, the driver will use
the given Calendar object to construct the SQL DATE
value to send to the database. With a
Calendar object, the driver can calculate the date
taking into account a custom time zone. If no Calendar
object is specified, the driver uses the time zone of the Virtual Machine
that is running the application.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setDate
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given java.sql.Date object.
The second element is the value set for cal.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the date being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
Object date[];
checkParamIndex(parameterIndex);
date = new Object[2];
date[0] = x;
date[1] = cal;
if(params == null){
throw new SQLException("Set initParams() before setDate");
}
params.put(new Integer(parameterIndex - 1), date);
| public void | setDouble(int parameterIndex, double x)Sets the designated parameter to the given double in the
Java programming language. The driver converts this to an SQL
DOUBLE value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
S
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setDouble");
}
params.put(new Integer(parameterIndex - 1), new Double(x));
| public void | setEscapeProcessing(boolean enable)Sets to the given boolean whether or not the driver will
scan for escape syntax and do escape substitution before sending SQL
statements to the database. The default is for the driver to do escape
processing.
Note: Since PreparedStatement objects have usually been
parsed prior to making this call, disabling escape processing for
prepared statements will likely have no effect.
escapeProcessing = enable;
| public void | setFetchDirection(int direction)Gives the driver a performance hint as to the direction in
which the rows in this RowSet object will be
processed. The driver may ignore this hint.
A RowSet object inherits the default properties of the
ResultSet object from which it got its data. That
ResultSet object's default fetch direction is set by
the Statement object that created it.
This method applies to a RowSet object only while it is
connected to a database using a JDBC driver.
A RowSet object may use this method at any time to change
its setting for the fetch direction.
// Changed the condition checking to the below as there were two
// conditions that had to be checked
// 1. RowSet is TYPE_FORWARD_ONLY and direction is not FETCH_FORWARD
// 2. Direction is not one of the valid values
if (((getType() == ResultSet.TYPE_FORWARD_ONLY) && (direction != ResultSet.FETCH_FORWARD)) ||
((direction != ResultSet.FETCH_FORWARD) &&
(direction != ResultSet.FETCH_REVERSE) &&
(direction != ResultSet.FETCH_UNKNOWN))) {
throw new SQLException("Invalid Fetch Direction");
}
fetchDir = direction;
| public void | setFetchSize(int rows)Sets the fetch size for this RowSet object to the given number of
rows. The fetch size gives a JDBC technology-enabled driver ("JDBC driver")
a hint as to the
number of rows that should be fetched from the database when more rows
are needed for this RowSet object. If the fetch size specified
is zero, the driver ignores the value and is free to make its own best guess
as to what the fetch size should be.
A RowSet object inherits the default properties of the
ResultSet object from which it got its data. That
ResultSet object's default fetch size is set by
the Statement object that created it.
This method applies to a RowSet object only while it is
connected to a database using a JDBC driver.
For connected RowSet implementations such as
JdbcRowSet , this method has a direct and immediate effect
on the underlying JDBC driver.
A RowSet object may use this method at any time to change
its setting for the fetch size.
For RowSet implementations such as
CachedRowSet , which operate in a disconnected environment,
the SyncProvider object being used
may leverage the fetch size to poll the data source and
retrieve a number of rows that do not exceed the fetch size and that may
form a subset of the actual rows returned by the original query. This is
an implementation variance determined by the specific SyncProvider
object employed by the disconnected RowSet object.
//Added this checking as maxRows can be 0 when this function is called
//maxRows = 0 means rowset can hold any number of rows, os this checking
// is needed to take care of this condition.
if (getMaxRows() == 0 && rows >= 0) {
fetchSize = rows;
return;
}
if ((rows < 0) || (rows > getMaxRows())) {
throw new SQLException("Invalid fetch size set. Cannot be of " +
"value: " + rows);
}
fetchSize = rows;
| public void | setFloat(int parameterIndex, float x)Sets the designated parameter to the given float in the
Java programming language. The driver converts this to an SQL
FLOAT value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setFloat");
}
params.put(new Integer(parameterIndex - 1), new Float(x));
| public void | setInt(int parameterIndex, int x)Sets the designated parameter to an int in the Java
programming language. The driver converts this to an SQL
INTEGER value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setInt");
}
params.put(new Integer(parameterIndex - 1), new Integer(x));
| public void | setLong(int parameterIndex, long x)Sets the designated parameter to the given long in the Java
programming language. The driver converts this to an SQL
BIGINT value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setLong");
}
params.put(new Integer(parameterIndex - 1), new Long(x));
| public void | setMaxFieldSize(int max)Sets the maximum number of bytes that can be used for a column
value in this RowSet object to the given number.
This limit applies only to columns that hold values of the
following types: BINARY , VARBINARY ,
LONGVARBINARY , CHAR , VARCHAR ,
and LONGVARCHAR . If the limit is exceeded, the excess
data is silently discarded. For maximum portability, it is advisable to
use values greater than 256.
if (max < 0) {
throw new SQLException("Invalid max field size set. Cannot be of " +
"value: " + max);
}
maxFieldSize = max;
| public void | setMaxRows(int max)Sets the maximum number of rows that this RowSet object may contain to
the given number. If this limit is exceeded, the excess rows are
silently dropped.
if (max < 0) {
throw new SQLException("Invalid max row size set. Cannot be of " +
"value: " + max);
} else if (max < this.getFetchSize()) {
throw new SQLException("Invalid max row size set. Cannot be less " +
"than the fetchSize.");
}
this.maxRows = max;
| public void | setNull(int parameterIndex, int sqlType)Sets the designated parameter to SQL NULL .
Note that the parameter's SQL type must be specified using one of the
type codes defined in java.sql.Types . This SQL type is
specified in the second parameter.
Note that the second parameter tells the DBMS the data type of the value being
set to NULL . Some DBMSs require this information, so it is required
in order to make code more portable.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setNull
has been called will return an Object array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is null .
The second element is the value set for sqlType.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the second placeholder parameter is being set to
null , the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
Object nullVal[];
checkParamIndex(parameterIndex);
nullVal = new Object[2];
nullVal[0] = null;
nullVal[1] = new Integer(sqlType);
if (params == null){
throw new SQLException("Set initParams() before setNull");
}
params.put(new Integer(parameterIndex - 1), nullVal);
| public void | setNull(int parameterIndex, int sqlType, java.lang.String typeName)Sets the designated parameter to SQL NULL .
Although this version of the method setNull is intended
for user-defined
and REF parameters, this method may be used to set a null
parameter for any JDBC type. The following are user-defined types:
STRUCT , DISTINCT , and 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 user-defined or REF parameter.
In the case of a user-defined type, 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 technology-enabled
driver does not need the type code or type name information,
it may ignore it.
If the parameter does not have a user-defined or REF type,
the given typeName parameter is ignored.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setNull
has been called will return an Object array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is null .
The second element is the value set for sqlType, and the third
element is the value set for typeName.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the second placeholder parameter is being set to
null , the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
Object nullVal[];
checkParamIndex(parameterIndex);
nullVal = new Object[3];
nullVal[0] = null;
nullVal[1] = new Integer(sqlType);
nullVal[2] = new String(typeName);
if(params == null){
throw new SQLException("Set initParams() before setNull");
}
params.put(new Integer(parameterIndex - 1), nullVal);
| public void | setObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale)Sets the designated parameter to an Object in the Java
programming language. The second parameter must be an
Object type. For integral values, the
java.lang equivalent
objects should be used. For example, use the class Integer
for an int .
The driver converts this object to the specified
target SQL type before sending it to the database.
If the object has a custom mapping (is of a class implementing
SQLData ), the driver should call the method
SQLData.writeSQL to write the object to the SQL
data stream. If, on the other hand, the object is of a class
implementing Ref , Blob , Clob ,
Struct , or Array ,
the driver should pass it to the database as a value of the
corresponding SQL type.
Note that this method may be used to pass database-
specific abstract data types.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setObject
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given Object instance, and the
second element is the value set for targetSqlType. The
third element is the value set for scale, which the driver will
ignore if the type of the object being set is not
java.sql.Types.NUMERIC or java.sql.Types.DECIMAL .
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the object being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
Object obj[];
checkParamIndex(parameterIndex);
obj = new Object[3];
obj[0] = x;
obj[1] = new Integer(targetSqlType);
obj[2] = new Integer(scale);
if(params == null){
throw new SQLException("Set initParams() before setObject");
}
params.put(new Integer(parameterIndex - 1), obj);
| public void | setObject(int parameterIndex, java.lang.Object x, int targetSqlType)Sets the value of the designated parameter with the given
Object value.
This method is like setObject(int parameterIndex, Object x, int
targetSqlType, int scale) except that it assumes a scale of zero.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setObject
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given Object instance.
The second element is the value set for targetSqlType.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the object being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
Object obj[];
checkParamIndex(parameterIndex);
obj = new Object[2];
obj[0] = x;
obj[1] = new Integer(targetSqlType);
if (params == null){
throw new SQLException("Set initParams() before setObject");
}
params.put(new Integer(parameterIndex - 1), obj);
| public void | setObject(int parameterIndex, java.lang.Object x)Sets the designated parameter to an Object in the Java
programming language. The second parameter must be an
Object
type. For integral values, the java.lang equivalent
objects should be used. For example, use the class Integer
for an int .
The JDBC specification defines a standard mapping from
Java Object types to SQL types. The driver will
use this standard mapping to convert the given object
to its corresponding SQL type before sending it to the database.
If the object has a custom mapping (is of a class implementing
SQLData ), the driver should call the method
SQLData.writeSQL to write the object to the SQL
data stream.
If, on the other hand, the object is of a class
implementing Ref , Blob , Clob ,
Struct , or Array ,
the driver should pass it to the database as a value of the
corresponding SQL type.
This method throws an exception if there
is an ambiguity, for example, if the object is of a class
implementing more than one interface.
Note that this method may be used to pass database-specific
abstract data types.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
After this method has been called, a call to the
method getParams
will return an object array of the current command parameters, which will
include the Object set for placeholder parameter number
parameterIndex .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
checkParamIndex(parameterIndex);
if (params == null) {
throw new SQLException("Set initParams() before setObject");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setPassword(java.lang.String pass)Sets the password used to create a database connection for this
RowSet object to the given String
object. Because the password property is not
serialized, it is set at run time before calling the method
execute .
if(pass == null)
{
password = null;
} else {
password = new String(pass);
}
| public void | setQueryTimeout(int seconds)Sets to the given number the maximum number of seconds the driver will
wait for a query to execute. If the limit is exceeded, an
SQLException is thrown.
if (seconds < 0) {
throw new SQLException("Invalid query timeout value set. Cannot be " +
"of value: " + seconds);
}
this.queryTimeout = seconds;
| public void | setReadOnly(boolean value)Sets this RowSet object's readOnly property to the given boolean .
readOnly = value;
| public void | setRef(int parameterIndex, java.sql.Ref ref)Sets the designated parameter to the given Ref object in
the Java programming language. The driver converts this to an SQL
REF value when it sends it to the database. Internally, the
Ref is represented as a SerialRef to ensure
serializability.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
After this method has been called, a call to the
method getParams
will return an object array of the current command parameters, which will
include the Ref object set for placeholder parameter number
parameterIndex .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
checkParamIndex(parameterIndex);
if (params == null) {
throw new SQLException("Set initParams() before setRef");
}
params.put(new Integer(parameterIndex - 1), new SerialRef(ref));
| public void | setShort(int parameterIndex, short x)Sets the designated parameter to the given short in the
Java programming language. The driver converts this to an SQL
SMALLINT value when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setShort");
}
params.put(new Integer(parameterIndex - 1), new Short(x));
| public void | setShowDeleted(boolean value)Sets the property showDeleted to the given
boolean value, which determines whether
rows marked for deletion appear in the set of current rows.
showDeleted = value;
| public void | setString(int parameterIndex, java.lang.String x)Sets the designated parameter to the given String
value. 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) when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setString");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setTime(int parameterIndex, java.sql.Time x)Sets the designated parameter to the given java.sql.Time
value. The driver converts this to an SQL TIME value
when it sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version
of the method setTime
has been called will return an array of the parameters that have been set.
The parameter to be set for parameter placeholder number parameterIndex
will be the Time object that was set as the second parameter
to this method.
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setTime");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setTime(int parameterIndex, java.sql.Time x, java.util.Calendar cal)Sets the designated parameter to the given java.sql.Time
object. The driver converts this
to an SQL TIME value when it sends it to the database.
When the DBMS does not store time zone information, the driver will use
the given Calendar object to construct the SQL TIME
value to send to the database. With a
Calendar object, the driver can calculate the date
taking into account a custom time zone. If no Calendar
object is specified, the driver uses the time zone of the Virtual Machine
that is running the application.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setTime
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given java.sql.Time object.
The second element is the value set for cal.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the time being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
Object time[];
checkParamIndex(parameterIndex);
time = new Object[2];
time[0] = x;
time[1] = cal;
if(params == null){
throw new SQLException("Set initParams() before setTime");
}
params.put(new Integer(parameterIndex - 1), time);
| public void | setTimestamp(int parameterIndex, java.sql.Timestamp x)Sets the designated parameter to the given
java.sql.Timestamp value.
The driver converts this to an SQL TIMESTAMP value when it
sends it to the database.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setTimestamp
has been called will return an array with the value for parameter placeholder
number parameterIndex being the Timestamp object that was
supplied as the second parameter to this method.
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
checkParamIndex(parameterIndex);
if(params == null){
throw new SQLException("Set initParams() before setTimestamp");
}
params.put(new Integer(parameterIndex - 1), x);
| public void | setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar cal)Sets the designated parameter to the given
java.sql.Timestamp object. The driver converts this
to an SQL TIMESTAMP value when it sends it to the database.
When the DBMS does not store time zone information, the driver will use
the given Calendar object to construct the SQL TIMESTAMP
value to send to the database. With a
Calendar object, the driver can calculate the timestamp
taking into account a custom time zone. If no Calendar
object is specified, the driver uses the time zone of the Virtual Machine
that is running the application.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Methods such as execute and populate must be
provided in any class that extends this class and implements one or
more of the standard JSR-114 RowSet interfaces.
NOTE: JdbcRowSet does not require the populate method
as it is undefined in this class.
Calls made to the method getParams after this version of
setTimestamp
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given java.sql.Timestamp object.
The second element is the value set for cal.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the timestamp being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is parameterIndex -1.
Object timestamp[];
checkParamIndex(parameterIndex);
timestamp = new Object[2];
timestamp[0] = x;
timestamp[1] = cal;
if(params == null){
throw new SQLException("Set initParams() before setTimestamp");
}
params.put(new Integer(parameterIndex - 1), timestamp);
| public void | setTransactionIsolation(int level)Sets the transaction isolation property for this JDBC RowSet object to the given
constant. The DBMS will use this transaction isolation level for
transactions if it can.
For RowSet implementations such as
the CachedRowSet that operate in a disconnected environment,
the SyncProvider object being used
offers complementary locking and data integrity options. The
options described below are pertinent only to connected RowSet
objects (JdbcRowSet objects).
if ((level != Connection.TRANSACTION_NONE) &&
(level != Connection.TRANSACTION_READ_COMMITTED) &&
(level != Connection.TRANSACTION_READ_UNCOMMITTED) &&
(level != Connection.TRANSACTION_REPEATABLE_READ) &&
(level != Connection.TRANSACTION_SERIALIZABLE))
{
throw new SQLException("Invalid transaction isolation set. Must " +
"be either " +
"Connection.TRANSACTION_NONE or " +
"Connection.TRANSACTION_READ_UNCOMMITTED or " +
"Connection.TRANSACTION_READ_COMMITTED or " +
"Connection.RRANSACTION_REPEATABLE_READ or " +
"Connection.TRANSACTION_SERIALIZABLE");
}
this.isolation = level;
| public void | setType(int type)Sets the type for this RowSet object to the specified type.
The default type is ResultSet.TYPE_SCROLL_INSENSITIVE .
if ((type != ResultSet.TYPE_FORWARD_ONLY) &&
(type != ResultSet.TYPE_SCROLL_INSENSITIVE) &&
(type != ResultSet.TYPE_SCROLL_SENSITIVE)) {
throw new SQLException("Invalid type of RowSet set. Must be either " +
"ResultSet.TYPE_FORWARD_ONLY or ResultSet.TYPE_SCROLL_INSENSITIVE " +
"or ResultSet.TYPE_SCROLL_SENSITIVE.");
}
this.rowSetType = type;
| public void | setTypeMap(java.util.Map map)Installs the given java.util.Map object as the type map
associated with the Connection object for this
RowSet object. The custom mapping indicated in
this type map will be used unless a different type map is explicitly
supplied to a method, in which case the type map supplied will be used.
this.map = map;
| public void | setUnicodeStream(int parameterIndex, java.io.InputStream x, int length)Sets the designated parameter to the given
java.io.InputStream object, which will have the specified
number of bytes. The contents of the stream will be read and sent
to the database.
This method throws an SQLException if the number of bytes
read and sent to the database is not equal to length.
When a very large Unicode value is input to a
LONGVARCHAR parameter, it may be more practical
to send it via a java.io.InputStream object.
A JDBC technology-enabled driver will read the data from the
stream as needed, until it reaches end-of-file.
The driver will do any necessary conversion from Unicode to the
database CHAR format.
The byte format of the Unicode stream must be Java UTF-8, as
defined in the Java Virtual Machine Specification.
Note: This stream object can be either a standard
Java stream object or your own subclass that implements the
standard interface.
This method is deprecated; the method getCharacterStream
should be used in its place.
The parameter value set by this method is stored internally and
will be supplied as the appropriate parameter in this RowSet
object's command when the method execute is called.
Calls made to the method getParams after setUnicodeStream
has been called will return an array containing the parameter values that
have been set. In that array, the element that represents the values
set with this method will itself be an array. The first element of that array
is the given java.io.InputStream object.
The second element is the value set for length.
The third element is an internal BaseRowSet constant
specifying that the stream passed to this method is a Unicode stream.
The parameter number is indicated by an element's position in the array
returned by the method getParams ,
with the first element being the value for the first placeholder parameter, the
second element being the value for the second placeholder parameter, and so on.
In other words, if the input stream being set is the value for the second
placeholder parameter, the array containing it will be the second element in
the array returned by getParams .
Note that because the numbering of elements in an array starts at zero,
the array element that corresponds to placeholder parameter number
parameterIndex is element number parameterIndex -1.
Object unicodeStream[];
checkParamIndex(parameterIndex);
unicodeStream = new Object[3];
unicodeStream[0] = x;
unicodeStream[1] = new Integer(length);
unicodeStream[2] = new Integer(UNICODE_STREAM_PARAM);
if(params == null){
throw new SQLException("Set initParams() before setUnicodeStream");
}
params.put(new Integer(parameterIndex - 1), unicodeStream);
| public void | setUrl(java.lang.String url)Sets the Url property for this RowSet object
to the given String object and sets the dataSource name
property to null . The Url property is a
JDBC URL that is used when
the connection is created using a JDBC technology-enabled driver
("JDBC driver") and the DriverManager .
The correct JDBC URL for the specific driver to be used can be found
in the driver documentation. Although there are guidelines for for how
a JDBC URL is formed,
a driver vendor can specify any String object except
one with a length of 0 (an empty string).
Setting the Url property is optional if connections are established using
a DataSource object instead of the DriverManager .
The driver will use either the URL property or the
dataSourceName property to create a connection, whichever was
specified most recently. If an application uses a JDBC URL, it
must load a JDBC driver that accepts the JDBC URL before it uses the
RowSet object to connect to a database. The RowSet
object will use the URL internally to create a database connection in order
to read or write data.
if(url == null) {
url = null;
} else if (url.length() < 1) {
throw new SQLException("Invalid url string detected. " +
"Cannot be of length less than 1");
} else {
URL = new String(url);
}
dataSource = null;
| public void | setUsername(java.lang.String name)Sets the username property for this RowSet object
to the given user name. Because it
is not serialized, the username property is set at run time before
calling the method execute .
if(name == null)
{
username = null;
} else {
username = new String(name);
}
|
|