AutoCloseable
, PreparedStatement
, Statement
, Wrapper
AS400JDBCPreparedStatementImpl
, AS400JDBCPreparedStatementRedirect
public abstract class AS400JDBCPreparedStatement extends AS400JDBCStatement implements PreparedStatement
The AS400JDBCPreparedStatement class precompiles and stores an SQL statement. This provides the ability to efficiently run the statement multiple times. In addition, the statement may contain parameters. Use Connection.prepareStatement() to create new PreparedStatement objects.
When setting input parameter values, the caller must specify types that are compatible with the defined SQL type of the input parameter. For example, if the input parameter has SQL type INTEGER, then the caller must call setInt() to set the IN parameter value. If arbitrary type conversions are required, then use setObject() with a target SQL type.
For method that sets parameters, the application should not modify the parameter value until after the execute completes. Modifying a value between the setXXXX method and the execute method may result in unpredictable behavior.
extendedColumnDescriptors_
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
Modifier and Type | Method | Description |
---|---|---|
abstract void |
addBatch() |
Adds the set of parameters to the current batch.
|
abstract void |
addBatch(String sql) |
Adds an SQL statement to the current batch of SQL statements.
|
abstract void |
clearParameters() |
Releases the resources used by the current input parameter values.
|
abstract boolean |
execute() |
Runs an SQL statement that may return multiple result sets.
|
abstract boolean |
execute(String sql) |
Runs an SQL statement that may return multiple result sets.
|
abstract boolean |
execute(String sql,
int autoGeneratedKeys) |
Runs an SQL statement that may return multiple result sets and makes any
auto-generated keys available for retrieval using
Statement.getGeneratedKeys().
|
abstract int[] |
executeBatch() |
Runs the batch of SQL statements.
|
abstract long |
executeLargeUpdate() |
Executes the SQL statement in this PreparedStatement object, which
must be an SQL Data Manipulation Language (DML) statement, such as
INSERT, UPDATE or DELETE; or an SQL statement that returns nothing,
such as a DDL statement.
|
abstract ResultSet |
executeQuery() |
Runs the SQL statement that returns a single result set.
|
abstract ResultSet |
executeQuery(String sql) |
Runs an SQL statement that returns a single result set.
|
abstract int |
executeUpdate() |
Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that
does not return a result set.
|
abstract int |
executeUpdate(String sql) |
Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that
does not return a result set.
|
abstract int |
executeUpdate(String sql,
int autoGeneratedKeys) |
Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that
does not return a result set and makes any auto-generated keys available
for retrieval using Statement.getGeneratedKeys().
|
abstract String |
getDB2ParameterName(int parm) |
Return the name of the parameter for a stored procedure call.
|
abstract ResultSetMetaData |
getMetaData() |
Returns the ResultSetMetaData object that describes the result set's
columns.
|
abstract ParameterMetaData |
getParameterMetaData() |
Returns the number, types, and properties of a PreparedStatement object's
parameters.
|
protected String[] |
getValidWrappedList() |
|
boolean |
isWrapperFor(Class<?> iface) |
Returns true if this either implements the interface argument or is
directly or indirectly a wrapper for an object that does.
|
abstract void |
setArray(int parameterIndex,
Array parameterValue) |
Sets an input parameter to an Array value.
|
abstract void |
setAsciiStream(int parameterIndex,
InputStream x) |
Sets the designated parameter to the given input stream.
|
abstract void |
setAsciiStream(int parameterIndex,
InputStream parameterValue,
int length) |
Sets an input parameter to an ASCII stream value.
|
abstract void |
setAsciiStream(int parameterIndex,
InputStream x,
long length) |
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
abstract void |
setBigDecimal(int parameterIndex,
BigDecimal parameterValue) |
Sets an input parameter to a BigDecimal value.
|
abstract void |
setBinaryStream(int parameterIndex,
InputStream x) |
Sets the designated parameter to the given input stream.
|
abstract void |
setBinaryStream(int parameterIndex,
InputStream parameterValue,
int length) |
Sets an input parameter to a binary stream value.
|
abstract void |
setBinaryStream(int parameterIndex,
InputStream x,
long length) |
Sets the designated parameter to the given input stream, which will have
the specified number of bytes.
|
abstract void |
setBlob(int parameterIndex,
InputStream inputStream) |
Sets the designated parameter to a
InputStream object. |
abstract void |
setBlob(int parameterIndex,
InputStream inputStream,
long length) |
Sets the designated parameter to an
InputStream object. |
abstract void |
setBlob(int parameterIndex,
Blob parameterValue) |
Sets an input parameter to a Blob value.
|
abstract void |
setBoolean(int parameterIndex,
boolean parameterValue) |
Sets an input parameter to a Java boolean value.
|
abstract void |
setByte(int parameterIndex,
byte parameterValue) |
Sets an input parameter to a Java byte value.
|
abstract void |
setBytes(int parameterIndex,
byte[] parameterValue) |
Sets an input parameter to a Java byte array value.
|
abstract void |
setCharacterStream(int parameterIndex,
Reader reader) |
Sets the designated parameter to the given
Reader object. |
abstract void |
setCharacterStream(int parameterIndex,
Reader parameterValue,
int length) |
Sets an input parameter to a character stream value.
|
abstract void |
setCharacterStream(int parameterIndex,
Reader reader,
long length) |
Sets the designated parameter to the given
Reader object,
which is the given number of characters long. |
abstract void |
setClob(int parameterIndex,
Reader reader) |
Sets the designated parameter to a
Reader object. |
abstract void |
setClob(int parameterIndex,
Reader reader,
long length) |
Sets the designated parameter to a
Reader object. |
abstract void |
setClob(int parameterIndex,
Clob parameterValue) |
Sets an input parameter to a Clob value.
|
abstract void |
setDate(int parameterIndex,
Date parameterValue) |
Sets an input parameter to a java.sql.Date value using the default
calendar.
|
abstract void |
setDate(int parameterIndex,
Date parameterValue,
Calendar calendar) |
Sets an input parameter to a java.sql.Date value using a calendar other
than the default.
|
abstract void |
setDB2Default(int parameterIndex) |
Sets an input parameter to the default value
|
abstract void |
setDB2Unassigned(int parameterIndex) |
Sets an input parameter to unassigned
|
abstract void |
setDBDefault(int parameterIndex) |
Sets an input parameter to the default value.
|
abstract void |
setDBUnassigned(int parameterIndex) |
Sets an input parameter to unassigned.
|
abstract void |
setDouble(int parameterIndex,
double parameterValue) |
Sets an input parameter to a Java double value.
|
abstract void |
setFloat(int parameterIndex,
float parameterValue) |
Sets an input parameter to a Java float value.
|
abstract void |
setInt(int parameterIndex,
int parameterValue) |
Sets an input parameter to a Java int value.
|
abstract void |
setLong(int parameterIndex,
long parameterValue) |
Sets an input parameter to a Java long value.
|
abstract void |
setNCharacterStream(int parameterIndex,
Reader value) |
Sets the designated parameter to a
Reader object. |
abstract void |
setNCharacterStream(int parameterIndex,
Reader value,
long length) |
Sets the designated parameter to a
Reader object. |
abstract void |
setNClob(int parameterIndex,
Reader reader) |
Sets the designated parameter to a
Reader object. |
abstract void |
setNClob(int parameterIndex,
Reader reader,
long length) |
Sets the designated parameter to a
Reader object. |
abstract void |
setNClob(int parameterIndex,
NClob value) |
Sets the designated parameter to a
java.sql.NClob object. |
abstract void |
setNString(int parameterIndex,
String value) |
Sets the designated paramter to the given
String object. |
abstract void |
setNull(int parameterIndex,
int sqlType) |
Sets an input parameter to SQL NULL.
|
abstract void |
setNull(int parameterIndex,
int sqlType,
String typeName) |
Sets an input parameter to SQL NULL.
|
abstract void |
setObject(int parameterIndex,
Object parameterValue) |
Sets an input parameter to an Object value.
|
abstract void |
setObject(int parameterIndex,
Object parameterValue,
int sqlType) |
Sets an input parameter to an Object value.
|
abstract void |
setObject(int parameterIndex,
Object parameterValue,
int sqlType,
int scale) |
Sets an input parameter to an Object value.
|
abstract void |
setObject(int parameterIndex,
Object x,
SQLType targetSqlType) |
Sets the value of the designated parameter with the given object.
|
abstract void |
setObject(int parameterIndex,
Object x,
SQLType targetSqlType,
int scaleOrLength) |
Sets the value of the designated parameter with the given object.
|
abstract void |
setRef(int parameterIndex,
Ref parameterValue) |
Sets an input parameter to a Ref value.
|
abstract void |
setRowId(int parameterIndex,
RowId x) |
Sets the designated parameter to the given
java.sql.RowId object. |
abstract void |
setShort(int parameterIndex,
short parameterValue) |
Sets an input parameter to a Java short value.
|
abstract void |
setSQLXML(int parameterIndex,
SQLXML xmlObject) |
Sets the designated parameter to the given
java.sql.SQLXML object. |
abstract void |
setString(int parameterIndex,
String parameterValue) |
Sets an input parameter to a String value.
|
abstract void |
setTime(int parameterIndex,
Time parameterValue) |
Sets an input parameter to a java.sql.Time value using the default
calendar.
|
abstract void |
setTime(int parameterIndex,
Time parameterValue,
Calendar calendar) |
Sets an input parameter to a java.sql.Time value using a calendar other
than the default.
|
abstract void |
setTimestamp(int parameterIndex,
Timestamp parameterValue) |
Sets an input parameter to a java.sql.Timestamp value using the default
calendar.
|
abstract void |
setTimestamp(int parameterIndex,
Timestamp parameterValue,
Calendar calendar) |
Sets an input parameter to a java.sql.Timestamp value using a calendar
other than the default.
|
abstract void |
setUnicodeStream(int parameterIndex,
InputStream parameterValue,
int length) |
Deprecated.
Use setCharacterStream(int, Reader, int) instead.
|
abstract void |
setURL(int parameterIndex,
URL parameterValue) |
Sets an input parameter to a URL value.
|
<T> T |
unwrap(Class<T> iface) |
Returns an object that implements the given interface to allow access to
non-standard methods, or standard methods not exposed by the proxy.
|
cancel, clearBatch, clearWarnings, close, closeOnCompletion, endCancelThread, execute, execute, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, finalize, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getPositionOfSyntaxError, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, startCancelThread, toString
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
cancel, clearBatch, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
isWrapperFor, unwrap
public abstract void addBatch() throws SQLException
addBatch
in interface PreparedStatement
SQLException
- If the statement is not open or an input parameter has not
been set.public abstract void addBatch(String sql) throws SQLException
Do not use this form of addBatch() on a prepared statement.
addBatch
in interface Statement
addBatch
in class AS400JDBCStatement
sql
- The SQL statement to be added to the current batch. This can be
any SQL statement that does not return a result set.SQLException
- This exception is always thrown.public abstract void clearParameters() throws SQLException
clearParameters
in interface PreparedStatement
SQLException
- If the statement is not open.public abstract boolean execute() throws SQLException
Under some situations, a single SQL statement may return multiple result sets, an update count, or both. This might occur either when executing a stored procedure that returns multiple result sets or when dynamically executing an unknown SQL string.
Use Statement.getMoreResults(), Statement.getResultSet(), and Statement.getUpdateCount() to navigate through multiple result sets, an update count, or both.
execute
in interface PreparedStatement
SQLException
- If the statement is not open, the query timeout limit is
exceeded, or an error occurs.public abstract boolean execute(String sql) throws SQLException
Do not use this form of execute() on a prepared statement.
execute
in interface Statement
execute
in class AS400JDBCStatement
sql
- The SQL statement.SQLException
- This exception is always thrown.public abstract boolean execute(String sql, int autoGeneratedKeys) throws SQLException
Do not use this form of execute() on a prepared statement.
execute
in interface Statement
execute
in class AS400JDBCStatement
sql
- The SQL statement.autoGeneratedKeys
- Indicates whether auto-generated keys should be made available for
retrieval. Valid values are Statement.RETURN_GENERATED_KEYS and
Statement.NO_GENERATED_KEYS.SQLException
- This exception is always thrown.public abstract int[] executeBatch() throws SQLException
When batch updates are run, autocommit should usually be turned off. This allows the caller to decide whether or not to commit the transaction in the event that an error occurs and some of the SQL statements in a batch fail to run.
executeBatch
in interface Statement
executeBatch
in class AS400JDBCStatement
SQLException
- If the statement is not open, an SQL statement contains a
syntax error, the query timeout limit is exceeded, an SQL
statement returns a result set, or an error occurs.public abstract ResultSet executeQuery() throws SQLException
executeQuery
in interface PreparedStatement
SQLException
- If the statement is not open, no result set is returned by the
database, the query timeout limit is exceeded, an input
parameter has not been set, or an error occurs.public abstract ResultSet executeQuery(String sql) throws SQLException
Do not use this form of executeQuery() on a prepared statement.
executeQuery
in interface Statement
executeQuery
in class AS400JDBCStatement
sql
- The SQL statement.SQLException
- This exception is always thrown.public abstract int executeUpdate() throws SQLException
executeUpdate
in interface PreparedStatement
SQLException
- If the statement is not open, the query timeout limit is
exceeded, the statement returns a result set, an input
parameter has not been set, or an error occurs.public abstract int executeUpdate(String sql) throws SQLException
Do not use this form of executeUpdate() on a prepared statement.
executeUpdate
in interface Statement
executeUpdate
in class AS400JDBCStatement
sql
- The SQL statement.SQLException
- This exception is always thrown.public abstract int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
Do not use this form of executeUpdate() on a prepared statement.
executeUpdate
in interface Statement
executeUpdate
in class AS400JDBCStatement
sql
- The SQL statement.SQLException
- This exception is always thrown.public abstract ResultSetMetaData getMetaData() throws SQLException
PreparedStatement ps = connection .prepareStatement("INSERT INTO COLLECTION.TABLE VALUES(?)"); ResultSetMetaData rsmd = ps.getMetaData();
getMetaData
in interface PreparedStatement
SQLException
- If the statement is not open.public abstract ParameterMetaData getParameterMetaData() throws SQLException
getParameterMetaData
in interface PreparedStatement
SQLException
- If the statement is not open.public abstract void setArray(int parameterIndex, Array parameterValue) throws SQLException
setArray
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- Always thrown because DB2 for IBM i does not support arrays.public abstract void setAsciiStream(int parameterIndex, InputStream parameterValue, int length) throws SQLException
setAsciiStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.length
- The number of bytes in the stream.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the length is not valid,
the input stream does not contain all ASCII characters, or an
error occurs while reading the input stream.public abstract void setBigDecimal(int parameterIndex, BigDecimal parameterValue) throws SQLException
setBigDecimal
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setBinaryStream(int parameterIndex, InputStream parameterValue, int length) throws SQLException
setBinaryStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.length
- The number of bytes in the stream.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the length is not valid,
or an error occurs while reading the input stream.public abstract void setBlob(int parameterIndex, Blob parameterValue) throws SQLException
setBlob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the parameter is not
serializable (when proxy support is in use).public abstract void setBoolean(int parameterIndex, boolean parameterValue) throws SQLException
setBoolean
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setByte(int parameterIndex, byte parameterValue) throws SQLException
setByte
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setBytes(int parameterIndex, byte[] parameterValue) throws SQLException
setBytes
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setCharacterStream(int parameterIndex, Reader parameterValue, int length) throws SQLException
setCharacterStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.length
- The number of characters to read from the reader.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the length is not valid,
or an error occurs while reading the character streampublic abstract void setClob(int parameterIndex, Clob parameterValue) throws SQLException
setClob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the parameter is not
serializable (when proxy support is in use).public abstract void setDate(int parameterIndex, Date parameterValue) throws SQLException
setDate
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setDate(int parameterIndex, Date parameterValue, Calendar calendar) throws SQLException
setDate
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.calendar
- The calendar.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the calendar is null.public abstract void setDB2Default(int parameterIndex) throws SQLException
parameterIndex
- The parameter index (1-based).SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter.public abstract void setDBDefault(int parameterIndex) throws SQLException
parameterIndex
- The parameter index (1-based).SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter.public abstract void setDB2Unassigned(int parameterIndex) throws SQLException
parameterIndex
- The parameter index (1-based).SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter.public abstract void setDBUnassigned(int parameterIndex) throws SQLException
parameterIndex
- The parameter index (1-based).SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter.public abstract void setDouble(int parameterIndex, double parameterValue) throws SQLException
setDouble
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid or the
parameter is not an input parameter.public abstract void setFloat(int parameterIndex, float parameterValue) throws SQLException
setFloat
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setInt(int parameterIndex, int parameterValue) throws SQLException
setInt
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid or the
parameter is not an input parameter.public abstract void setLong(int parameterIndex, long parameterValue) throws SQLException
setLong
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setNull(int parameterIndex, int sqlType) throws SQLException
setNull
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).sqlType
- The SQL type code defined in java.sql.Types.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the SQL type is not
valid.public abstract void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException
setNull
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).sqlType
- The SQL type code defined in java.sql.Types.typeName
- The fully-qualified name of an SQL structured type. This value
will be ignored.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the SQL type is not
valid.public abstract void setObject(int parameterIndex, Object parameterValue) throws SQLException
setObject
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the type of value is not
supported, or the parameter is not serializable (when proxy
support is in use).public abstract void setObject(int parameterIndex, Object parameterValue, int sqlType) throws SQLException
setObject
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.sqlType
- The SQL type code defined in java.sql.Types.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the SQL type is not
valid, or the parameter is not serializable (when proxy
support is in use).public abstract void setObject(int parameterIndex, Object parameterValue, int sqlType, int scale) throws SQLException
setObject
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.sqlType
- The SQL type code defined in java.sql.Types.scale
- The number of digits after the decimal if sqlType is DECIMAL or
NUMERIC.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the SQL type is not
valid, the scale is not valid, or the parameter is not
serializable (when proxy support is in use).public abstract void setRef(int parameterIndex, Ref parameterValue) throws SQLException
setRef
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- Always thrown because DB2 for IBM i does not support structured types.public abstract void setShort(int parameterIndex, short parameterValue) throws SQLException
setShort
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.SQLException
- If the statement is not open, the index is not valid or the
parameter is not an input parameter.public abstract void setString(int parameterIndex, String parameterValue) throws SQLException
setString
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setTime(int parameterIndex, Time parameterValue) throws SQLException
setTime
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setTime(int parameterIndex, Time parameterValue, Calendar calendar) throws SQLException
setTime
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.calendar
- The calendar.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the calendar is null.public abstract void setTimestamp(int parameterIndex, Timestamp parameterValue) throws SQLException
setTimestamp
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setTimestamp(int parameterIndex, Timestamp parameterValue, Calendar calendar) throws SQLException
setTimestamp
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.calendar
- The calendar.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, or the calendar is null.public abstract void setUnicodeStream(int parameterIndex, InputStream parameterValue, int length) throws SQLException
Note that the number of bytes in a Unicode stream can be computed as 2 multiplied by the number of characters plus 2 bytes for the byte-order mark. If an uneven number of bytes is specified, then Java will convert this to an empty String.
setUnicodeStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.length
- The number of bytes in the stream.SQLException
- If the statement is not open, the index is not valid, the
parameter is not an input parameter, the length is not valid,
the input stream does not contain all Unicode characters, or
an error occurs while reading the input streamsetCharacterStream(int, java.io.Reader, int)
public abstract void setURL(int parameterIndex, URL parameterValue) throws SQLException
setURL
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set the value to SQL NULL.SQLException
- If the statement is not open, the index is not valid, or the
parameter is not an input parameter.public abstract void setRowId(int parameterIndex, RowId x) throws SQLException
java.sql.RowId
object. The
driver converts this to a SQL ROWID
value when it sends it
to the databasesetRowId
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).x
- the parameter valueSQLException
- if a database access error occurspublic abstract void setNString(int parameterIndex, String value) throws SQLException
String
object. The
driver converts this to a SQL NCHAR
or NVARCHAR
or LONGNVARCHAR
value (depending on the argument's size
relative to the driver's limits on NVARCHAR
values) when it
sends it to the database.setNString
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).value
- the parameter valueSQLException
- If a database error occurs.
if the driver does not support national character sets; if the
driver can detect that a data conversion error could occur ; or
if a database access error occurspublic abstract void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
Reader
object. The
Reader
reads the data till end-of-file is reached. The driver
does the necessary conversion from Java character format to the national
character set in the database.setNCharacterStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).value
- the parameter valuelength
- the number of characters in the parameter data.SQLException
- If a database error occurs.
if the driver does not support national character sets; if the
driver can detect that a data conversion error could occur ; or
if a database access error occurspublic abstract void setNClob(int parameterIndex, NClob value) throws SQLException
java.sql.NClob
object. The driver converts this to a
SQL NCLOB
value when it sends it to the database.setNClob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).value
- the parameter valueSQLException
- if the driver does not support national
character sets; if the driver can detect that a data conversion
error could occur ; or if a database access error occurspublic abstract void setClob(int parameterIndex, Reader reader, long length) throws SQLException
Reader
object. The reader
must contain the number of characters specified by length otherwise a
SQLException
will be generated when the
PreparedStatement
is executed.setClob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).reader
- An object that contains the data to set the parameter value to.length
- the number of characters in the parameter data.SQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement, or if the length specified is less than zero.public abstract void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
InputStream
object. The
inputStream must contain the number of characters specified by length
otherwise a SQLException
will be generated when the
PreparedStatement
is executed.setBlob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).inputStream
- An object that contains the data to set the parameter value to.length
- the number of bytes in the parameter data.SQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement, if the length specified is less than zero or
if the number of bytes in the inputstream does not match the
specfied length.public abstract void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
Reader
object. The reader
must contain the number of characters specified by length otherwise a
SQLException
will be generated when the
PreparedStatement
is executed.setNClob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).reader
- An object that contains the data to set the parameter value to.length
- the number of characters in the parameter data.SQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement; if the length specified is less than zero; if
the driver does not support national character sets; if the
driver can detect that a data conversion error could occur; or if
a database access error occurspublic abstract void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
java.sql.SQLXML
object.setSQLXML
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).xmlObject
- a SQLXML
object that maps an SQL XML
valueSQLException
- if a database access error occursprotected String[] getValidWrappedList()
getValidWrappedList
in class AS400JDBCStatement
public abstract void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
LONGVARCHAR
parameter, it may be more practical to send it via
a java.io.InputStream
. Data will be read from the stream as
needed until end-of-file is reached. The JDBC driver will do any necessary
conversion from ASCII to the database char format.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setAsciiStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).x
- the Java input stream that contains the ASCII parameter valuelength
- the number of bytes in the streamSQLException
- if a database access error occurs or this method is called on
a closed PreparedStatement
public abstract void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
LONGVARBINARY
parameter, it may be more practical to send it
via a java.io.InputStream
object. The data will be read from
the stream as needed until end-of-file is reached.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setBinaryStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).x
- the java input stream which contains the binary parameter valuelength
- the number of bytes in the streamSQLException
- if a database access error occurs or this method is called on
a closed PreparedStatement
public abstract void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
Reader
object,
which is the given number of characters long. When a very large UNICODE
value is input to a LONGVARCHAR
parameter, it may be more
practical to send it via a java.io.Reader
object. The data
will be read from the stream as needed until end-of-file is reached. The
JDBC driver will do any necessary conversion from UNICODE to the database
char format.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setCharacterStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).reader
- the java.io.Reader
object that contains the Unicode
datalength
- the number of characters in the streamSQLException
- if a database access error occurs or this method is called on
a closed PreparedStatement
public abstract String getDB2ParameterName(int parm) throws SQLException
parm
- the parameter number to get the name forSQLException
- If a database error occurs.public abstract void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
LONGVARCHAR
parameter, it may be
more practical to send it via a java.io.InputStream
. Data will
be read from the stream as needed until end-of-file is reached. The JDBC
driver will do any necessary conversion from ASCII to the database char
format.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setAsciiStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).x
- the Java input stream that contains the ASCII parameter valueSQLException
- if parameterIndex does not correspond to a parameter marker in
the SQL statement; if a database access error occurs or this
method is called on a closed PreparedStatement
public abstract void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
LONGVARBINARY
parameter, it may be
more practical to send it via a java.io.InputStream
object.
The data will be read from the stream as needed until end-of-file is
reached.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
setBinaryStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).x
- the java input stream which contains the binary parameter valueSQLException
- if parameterIndex does not correspond to a parameter marker in
the SQL statement; if a database access error occurs or this
method is called on a closed PreparedStatement
public abstract void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
InputStream
object. This
method differs from the setBinaryStream (int, InputStream)
method because it informs the driver that the parameter value should be
sent to the server as a BLOB
. When the
setBinaryStream
method is used, the driver may have to do
extra work to determine whether the parameter data should be sent to the
server as a LONGVARBINARY
or a BLOB
setBlob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).inputStream
- An object that contains the data to set the parameter value to.SQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement; if a database access error occurs; this method
is called on a closed PreparedStatement
or if
parameterIndex does not correspond to a parameter marker in the
SQL statement,public abstract void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
Reader
object. When
a very large UNICODE value is input to a LONGVARCHAR
parameter, it may be more practical to send it via a
java.io.Reader
object. The data will be read from the stream
as needed until end-of-file is reached. The JDBC driver will do any
necessary conversion from UNICODE to the database char format.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Note: Consult your JDBC driver documentation to determine if it
might be more efficient to use a version of setCharacterStream
which takes a length parameter.
setCharacterStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).reader
- the java.io.Reader
object that contains the Unicode
dataSQLException
- if parameterIndex does not correspond to a parameter marker in
the SQL statement; if a database access error occurs or this
method is called on a closed PreparedStatement
public abstract void setClob(int parameterIndex, Reader reader) throws SQLException
Reader
object. This method
differs from the setCharacterStream (int, Reader)
method
because it informs the driver that the parameter value should be sent to
the server as a CLOB
. When the setCharacterStream
method is used, the driver may have to do extra work to determine whether
the parameter data should be sent to the server as a
LONGVARCHAR
or a CLOB
Note: Consult your JDBC driver documentation to determine if it
might be more efficient to use a version of setClob
which
takes a length parameter.
setClob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).reader
- An object that contains the data to set the parameter value to.SQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement; if a database access error occurs; this method
is called on a closed PreparedStatement
or if
parameterIndex does not correspond to a parameter marker in the
SQL statementpublic abstract void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
Reader
object. The
Reader
reads the data till end-of-file is reached. The driver
does the necessary conversion from Java character format to the national
character set in the database.
Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
Note: Consult your JDBC driver documentation to determine if it
might be more efficient to use a version of
setNCharacterStream
which takes a length parameter.
setNCharacterStream
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).value
- the parameter valueSQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement; if the driver does not support national
character sets; if the driver can detect that a data conversion
error could occur; if a database access error occurs; or this
method is called on a closed PreparedStatement
public abstract void setNClob(int parameterIndex, Reader reader) throws SQLException
Reader
object. This method
differs from the setCharacterStream (int, Reader)
method
because it informs the driver that the parameter value should be sent to
the server as a NCLOB
. When the
setCharacterStream
method is used, the driver may have to do
extra work to determine whether the parameter data should be sent to the
server as a LONGNVARCHAR
or a NCLOB
Note: Consult your JDBC driver documentation to determine if it
might be more efficient to use a version of setNClob
which
takes a length parameter.
setNClob
in interface PreparedStatement
parameterIndex
- The parameter index (1-based).reader
- An object that contains the data to set the parameter value to.SQLException
- If a database error occurs.
if parameterIndex does not correspond to a parameter marker in
the SQL statement; if the driver does not support national
character sets; if the driver can detect that a data conversion
error could occur; if a database access error occurs or this
method is called on a closed PreparedStatement
public abstract void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException
The given Java object will be converted to the given targetSqlType before being sent to the database. If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, NClob, Struct, java.net.URL, 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.
setObject
in interface PreparedStatement
parameterIndex
- - the first parameter is 1, the second is 2, ...x
- - the object containing the input parameter valuetargetSqlType
- - the SQL type to be sent to the database. The scale argument may
further qualify this type.scaleOrLength
- - for java.sql.JDBCType.DECIMAL or java.sql.JDBCType.NUMERIC
types, this is the number of digits after the decimal point. For Java Object types
InputStream and Reader, this is the length of the data in the stream or reader.
For all other types, this value will be ignored.SQLException
- - if parameterIndex does not correspond to a parameter
marker in the SQL statement; if a database access error occurs or this method
is called on a closed PreparedStatement or if the Java Object specified by x
is an InputStream or Reader object and the value of the scale parameter is
less than zeropublic abstract void setObject(int parameterIndex, Object x, SQLType targetSqlType) throws SQLException
setObject
in interface PreparedStatement
parameterIndex
- - the first parameter is 1, the second is 2, ...x
- - the object containing the input parameter valuetargetSqlType
- - the SQL type to be sent to the database parameterIndexSQLException
- - if parameterIndex does not correspond to a parameter marker
in the SQL statement; if a database access error occurs or this method is called
on a closed PreparedStatementpublic abstract long executeLargeUpdate() throws SQLException
This method should be used when the returned row count may exceed Integer.MAX_VALUE.
executeLargeUpdate
in interface PreparedStatement
SQLException
- - if a database access error occurs; this method is called on a
closed PreparedStatement or the SQL statement returns a ResultSet objectpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
on the wrapped object. If this does not
implement the interface and is not a wrapper, return false. This method
should be implemented as a low-cost operation compared to
unwrap
so that callers can use this method to avoid
expensive unwrap
calls that may fail. If this method
returns true then calling unwrap
with the same argument
should succeed.isWrapperFor
in interface Wrapper
iface
- a Class defining an interface.SQLException
- If a database error occurs.
if an error occurs while determining whether this is a
wrapper for an object with the given interface.public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
recursively on the wrapped object or a
proxy for that result. If the receiver is not a wrapper and does not
implement the interface, then an SQLException
is thrown.unwrap
in interface Wrapper
iface
- A Class defining an interface that the result must implement.SQLException
- If a database error occurs.
If no object found that implements the interfaceCopyright © 2024. All rights reserved.