|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.access.AS400JDBCStatement | +--com.ibm.as400.access.AS400JDBCPreparedStatement
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.
Method Summary | |
void |
addBatch()
Adds the set of parameters to the current batch. |
void |
addBatch(java.lang.String sql)
Adds an SQL statement to the current batch of SQL statements. |
void |
clearParameters()
Releases the resources used by the current input parameter values. |
void |
close()
Releases the prepared statement's resources immediately instead of waiting for them to be automatically released. |
boolean |
execute()
Runs an SQL statement that may return multiple result sets. |
boolean |
execute(java.lang.String sql)
Runs an SQL statement that may return multiple result sets. |
int[] |
executeBatch()
Runs the batch of SQL statements. |
java.sql.ResultSet |
executeQuery()
Runs the SQL statement that returns a single result set. |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Runs an SQL statement that returns a single result set. |
int |
executeUpdate()
Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that does not return a result set. |
int |
executeUpdate(java.lang.String sql)
Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that does not return a result set. |
java.sql.ResultSetMetaData |
getMetaData()
Returns the ResultSetMetaData object that describes the result set's columns. |
void |
setArray(int parameterIndex,
java.sql.Array parameterValue)
Sets an input parameter to an Array value. |
void |
setAsciiStream(int parameterIndex,
java.io.InputStream parameterValue,
int length)
Sets an input parameter to an ASCII stream value. |
void |
setBigDecimal(int parameterIndex,
java.math.BigDecimal parameterValue)
Sets an input parameter to a BigDecimal value. |
void |
setBinaryStream(int parameterIndex,
java.io.InputStream parameterValue,
int length)
Sets an input parameter to a binary stream value. |
void |
setBlob(int parameterIndex,
java.sql.Blob parameterValue)
Sets an input parameter to a Blob value. |
void |
setBoolean(int parameterIndex,
boolean parameterValue)
Sets an input parameter to a Java boolean value. |
void |
setByte(int parameterIndex,
byte parameterValue)
Sets an input parameter to a Java byte value. |
void |
setBytes(int parameterIndex,
byte[] parameterValue)
Sets an input parameter to a Java byte array value. |
void |
setCharacterStream(int parameterIndex,
java.io.Reader parameterValue,
int length)
Sets an input parameter to a character stream value. |
void |
setClob(int parameterIndex,
java.sql.Clob parameterValue)
Sets an input parameter to a Clob value. |
void |
setDate(int parameterIndex,
java.sql.Date parameterValue)
Sets an input parameter to a java.sql.Date value using the default calendar. |
void |
setDate(int parameterIndex,
java.sql.Date parameterValue,
java.util.Calendar calendar)
Sets an input parameter to a java.sql.Date value using a calendar other than the default. |
void |
setDouble(int parameterIndex,
double parameterValue)
Sets an input parameter to a Java double value. |
void |
setFloat(int parameterIndex,
float parameterValue)
Sets an input parameter to a Java float value. |
void |
setInt(int parameterIndex,
int parameterValue)
Sets an input parameter to a Java int value. |
void |
setLong(int parameterIndex,
long parameterValue)
Sets an input parameter to a Java long value. |
void |
setNull(int parameterIndex,
int sqlType)
Sets an input parameter to SQL NULL. |
void |
setNull(int parameterIndex,
int sqlType,
java.lang.String typeName)
Sets an input parameter to SQL NULL. |
void |
setObject(int parameterIndex,
java.lang.Object parameterValue)
Sets an input parameter to an Object value. |
void |
setObject(int parameterIndex,
java.lang.Object parameterValue,
int sqlType)
Sets an input parameter to an Object value. |
void |
setObject(int parameterIndex,
java.lang.Object parameterValue,
int sqlType,
int scale)
Sets an input parameter to an Object value. |
void |
setRef(int parameterIndex,
java.sql.Ref parameterValue)
Sets an input parameter to a Ref value. |
void |
setShort(int parameterIndex,
short parameterValue)
Sets an input parameter to a Java short value. |
void |
setString(int parameterIndex,
java.lang.String parameterValue)
Sets an input parameter to a String value. |
void |
setTime(int parameterIndex,
java.sql.Time parameterValue)
Sets an input parameter to a java.sql.Time value using the default calendar. |
void |
setTime(int parameterIndex,
java.sql.Time parameterValue,
java.util.Calendar calendar)
Sets an input parameter to a java.sql.Time value using a calendar other than the default. |
void |
setTimestamp(int parameterIndex,
java.sql.Timestamp parameterValue)
Sets an input parameter to a java.sql.Timestamp value using the default calendar. |
void |
setTimestamp(int parameterIndex,
java.sql.Timestamp parameterValue,
java.util.Calendar calendar)
Sets an input parameter to a java.sql.Timestamp value using a calendar other than the default. |
void |
setUnicodeStream(int parameterIndex,
java.io.InputStream parameterValue,
int length)
Deprecated. Use setCharacterStream(int, Reader, int) instead. |
Methods inherited from class com.ibm.as400.access.AS400JDBCStatement |
cancel,
clearBatch,
clearWarnings,
finalize,
getConnection,
getFetchDirection,
getFetchSize,
getMaxFieldSize,
getMaxRows,
getMoreResults,
getQueryTimeout,
getResultSet,
getResultSetConcurrency,
getResultSetType,
getUpdateCount,
getWarnings,
setCursorName,
setEscapeProcessing,
setFetchDirection,
setFetchSize,
setMaxFieldSize,
setMaxRows,
setQueryTimeout,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Method Detail |
public void addBatch() throws java.sql.SQLException
public void addBatch(java.lang.String sql) throws java.sql.SQLException
Do not use this form of addBatch() on a prepared statement.
sql
- The SQL statement to be added to the current batch.
This can be any SQL statement that does not return
a result set.public void clearParameters() throws java.sql.SQLException
public void close() throws java.sql.SQLException
public boolean execute() throws java.sql.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.
public boolean execute(java.lang.String sql) throws java.sql.SQLException
Do not use this form of execute() on a prepared statement.
sql
- The SQL statement.public int[] executeBatch() throws java.sql.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.
public java.sql.ResultSet executeQuery() throws java.sql.SQLException
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
Do not use this form of executeQuery() on a prepared statement.
sql
- The SQL statement.public int executeUpdate() throws java.sql.SQLException
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
Do not use this form of executeUpdate() on a prepared statement.
sql
- The SQL statement.public java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException
public void setArray(int parameterIndex, java.sql.Array parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setAsciiStream(int parameterIndex, java.io.InputStream parameterValue, int length) throws java.sql.SQLException
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.public void setBigDecimal(int parameterIndex, java.math.BigDecimal parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setBinaryStream(int parameterIndex, java.io.InputStream parameterValue, int length) throws java.sql.SQLException
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.public void setBlob(int parameterIndex, java.sql.Blob parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setBoolean(int parameterIndex, boolean parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setByte(int parameterIndex, byte parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setBytes(int parameterIndex, byte[] parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setCharacterStream(int parameterIndex, java.io.Reader parameterValue, int length) throws java.sql.SQLException
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 reader.public void setClob(int parameterIndex, java.sql.Clob parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setDate(int parameterIndex, java.sql.Date parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setDate(int parameterIndex, java.sql.Date parameterValue, java.util.Calendar calendar) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.calendar
- The calendar.public void setDouble(int parameterIndex, double parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setFloat(int parameterIndex, float parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setInt(int parameterIndex, int parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setLong(int parameterIndex, long parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setNull(int parameterIndex, int sqlType) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).sqlType
- The SQL type code defined in java.sql.Types.public void setNull(int parameterIndex, int sqlType, java.lang.String typeName) throws java.sql.SQLException
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.public void setObject(int parameterIndex, java.lang.Object parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setObject(int parameterIndex, java.lang.Object parameterValue, int sqlType) throws java.sql.SQLException
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.public void setObject(int parameterIndex, java.lang.Object parameterValue, int sqlType, int scale) throws java.sql.SQLException
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.public void setRef(int parameterIndex, java.sql.Ref parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setShort(int parameterIndex, short parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value.public void setString(int parameterIndex, java.lang.String parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setTime(int parameterIndex, java.sql.Time parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setTime(int parameterIndex, java.sql.Time parameterValue, java.util.Calendar calendar) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.calendar
- The calendar.public void setTimestamp(int parameterIndex, java.sql.Timestamp parameterValue) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.public void setTimestamp(int parameterIndex, java.sql.Timestamp parameterValue, java.util.Calendar calendar) throws java.sql.SQLException
parameterIndex
- The parameter index (1-based).parameterValue
- The parameter value or null to set
the value to SQL NULL.calendar
- The calendar.public void setUnicodeStream(int parameterIndex, java.io.InputStream parameterValue, int length) throws java.sql.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.
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.setCharacterStream(int, java.io.Reader, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |