| java.lang.Object org.continuent.sequoia.driver.Statement org.continuent.sequoia.driver.PreparedStatement
All known Subclasses: org.continuent.sequoia.driver.CallableStatement,
PreparedStatement | public class PreparedStatement extends Statement implements java.sql.PreparedStatement(Code) | | A SQL Statement is pre-compiled and stored in a
PreparedStatement object. This object can then be used to
efficiently execute this statement multiple times.
Note: The setXXX methods for setting IN parameter values must specify
types that are compatible with the defined SQL type of the input parameter.
For instance, if the IN parameter has SQL type Integer, then setInt should be
used.
If arbitrary parameter type conversions are required, then the setObject
method should be used with a target SQL type.
In the old days, this was just a dirty copy/paste from the PostgreSQL driver.
Some irrelevant comments are left-over here and there.
This class could maybe be splitted into DriverProcessedPreparedStatement and
ProxyModeProcessedStatement
See Also: DriverResultSet See Also: java.sql.PreparedStatement author: Emmanuel Cecchet author: Nicolas Modrzyk author: Marc Wick author: Jaco Swart version: 1.0 |
Inner Class :protected class BatchElement | |
Method Summary | |
public synchronized void | addBatch() | public void | clearParameters() In general, parameter values remain in force for repeated used of a
Statement . | public void | close() Release objects for garbage collection and call Statement.close(). | protected synchronized String | compileParameters(boolean fillEmptyParametersWithCSParamTag) Helper - this compiles the SQL query, inlining the parameters in the
request String. | protected String | doEscapeProcessing(String x) Escape the input string. | public boolean | execute() Some prepared statements return multiple results; the execute method
handles these complex statements as well as the simpler form of statements
handled by executeQuery() and executeUpdate() . | public int[] | executeBatch() | public java.sql.ResultSet | executeQuery() A Prepared SQL query is executed and its ResultSet is
returned. | public int | executeUpdate() Execute a SQL INSERT, UPDATE or DELETE statement. | public java.sql.ResultSetMetaData | getMetaData() Returns the MetaData for the last ResultSet
returned. | public ParameterMetaData | getParameterMetaData() Retrieves the number, types and properties of this
PreparedStatement object's parameters. | protected String[] | getParameterTagAndValue(int paramIndex) Return a stored parameter tag and value. | public void | setArray(int i, Array x) | public void | setAsciiStream(int parameterIndex, InputStream x, int 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. | public void | setBigDecimal(int parameterIndex, BigDecimal x) Sets a parameter to a java.lang.BigDecimal value. | public void | setBinaryStream(int parameterIndex, InputStream inStreamArg, int length) Stores a binary stream into parameters array, using an intermediate byte[].
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. | public void | setBlob(int paramIndex, Blob sqlBlobParam) | public void | setBoolean(int parameterIndex, boolean x) Sets a parameter to a Java boolean value. | public void | setByte(int parameterIndex, byte x) Sets a parameter to a Java byte value. | public void | setBytes(int parameterIndex, byte[] x) Sets a parameter to a Java array of bytes. | public void | setCharacterStream(int i, java.io.Reader x, int length) | public void | setClob(int i, java.sql.Clob clobArg) | public void | setDate(int parameterIndex, java.sql.Date x) Sets a parameter to a java.sql.Date value. | public void | setDate(int i, java.sql.Date d, java.util.Calendar cal) | public void | setDouble(int parameterIndex, double x) Sets a parameter to a Java double value. | public void | setFloat(int parameterIndex, float x) Sets a parameter to a Java float value. | public void | setInt(int parameterIndex, int x) Sets a parameter to a Java int value. | public void | setLong(int parameterIndex, long x) Sets a parameter to a Java long value. | public void | setNull(int parameterIndex, int sqlType) Sets a parameter to SQL NULL. | public void | setNull(int i, int t, String s) | public void | setObject(int parameterIndex, Object x, int targetSqlType, int scale) Sets the value of a parameter using an object; use the
java.lang equivalent objects for integral values.
The given Java object will be converted to the targetSqlType before being
sent to the database.
Note that this method may be used to pass database-specific abstract data
types. | public void | setObject(int parameterIndex, Object x, int targetSqlType) | public void | setObject(int parameterIndex, Object x) This stores an Object parameter into the parameters array. | protected void | setParameter(int paramIndex, String s) Stores a parameter into parameters String array. | void | setParameterWithTag(int paramIndex, String typeTag, String param) Stores parameter and its type as a quoted String, so the
controller can decode them back.
We could avoid inlining the arguments and just tag them and send them apart
as an object list. | public void | setRef(int i, Ref x) | public void | setShort(int parameterIndex, short x) Sets a parameter to a Java short value. | public void | setString(int parameterIndex, String x) Sets a parameter to a Java String value. | public void | setTime(int parameterIndex, Time x) Sets a parameter to a java.sql.Time value. | public void | setTime(int i, Time t, java.util.Calendar cal) | public void | setTimestamp(int parameterIndex, Timestamp x) Sets a parameter to a java.sql.Timestamp value. | public void | setTimestamp(int i, Timestamp t, java.util.Calendar cal) | public void | setURL(int parameterIndex, java.net.URL x) Sets the designated parameter to the given java.net.URL
value. | public void | setUnicodeStream(int parameterIndex, InputStream x, int 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. | public String | toString() Returns the SQL statement with the current template values substituted. | protected String | trimStringBuffer() Sets the length of the temporary buffer to zero and returns a trimmed
version of the buffer's content. |
sql | protected String sql(Code) | | Original, untouched request (only trimmed)
|
PreparedStatement | PreparedStatement(Connection connection, String sqlStatement, Driver driver)(Code) | | Constructor. Counts the number of question mark placeholders to size the
parameters array.
Parameters: connection - the instantiating connection Parameters: sqlStatement - the SQL statement with ? for IN markers Parameters: driver - the Driver used to create connections |
addBatch | public synchronized void addBatch() throws SQLException(Code) | | This parses the query and adds it to the current batch
throws: SQLException - if an error occurs |
clearParameters | public void clearParameters() throws SQLException(Code) | | In general, parameter values remain in force for repeated used of a
Statement . Setting a parameter value automatically clears
its previous value. However, in coms cases, it is useful to immediately
release the resources used by the current parameter values; this can be
done by calling clearParameters() .
exception: SQLException - if a database access error occurs |
close | public void close() throws SQLException(Code) | | Release objects for garbage collection and call Statement.close().
throws: SQLException - if an error occurs |
compileParameters | protected synchronized String compileParameters(boolean fillEmptyParametersWithCSParamTag) throws SQLException(Code) | | Helper - this compiles the SQL query, inlining the parameters in the
request String. This is identical to this.toString() except
it throws an exception if a parameter was not set.
Parameters: fillEmptyParametersWithCSParamTag - true if called from aCallableStatement the compiled query throws: SQLException - if an error occurs |
doEscapeProcessing | protected String doEscapeProcessing(String x)(Code) | | Escape the input string.
' is replaced by \'
\ is replaced by \\
if connection.escapeProcessing is set to true, surround the new string with
\'
Parameters: x - the string to process escaped string |
execute | public boolean execute() throws SQLException(Code) | | Some prepared statements return multiple results; the execute method
handles these complex statements as well as the simpler form of statements
handled by executeQuery() and executeUpdate() .
true if the next result is aResultSet; false if it is an update countor there are no more results exception: SQLException - if a database access error occurs |
executeBatch | public int[] executeBatch() throws BatchUpdateException(Code) | | Execute a batch of commands
an array containing update count that corresponding to the commandsthat executed successfully exception: BatchUpdateException - if an error occurs on one statement (thenumber of updated rows for the successfully executedstatements can be found inBatchUpdateException.getUpdateCounts()) |
executeQuery | public java.sql.ResultSet executeQuery() throws SQLException(Code) | | A Prepared SQL query is executed and its ResultSet is
returned.
a ResultSet that contains the data produced by the *query - never null . exception: SQLException - if a database access error occurs |
executeUpdate | public int executeUpdate() throws SQLException(Code) | | Execute a SQL INSERT, UPDATE or DELETE statement. In addition, SQL
statements that return nothing such as SQL DDL statements can be executed.
either the row count for INSERT ,UPDATE or DELETE ; or 0 for SQLstatements that return nothing. exception: SQLException - if a database access error occurs |
getParameterMetaData | public ParameterMetaData getParameterMetaData() throws SQLException(Code) | | Retrieves the number, types and properties of this
PreparedStatement object's parameters.
a ParameterMetaData object that contains informationabout the number, types and properties of thisPreparedStatement object's parameters exception: SQLException - if a database access error occurs See Also: ParameterMetaData since: JDK 1.4 |
getParameterTagAndValue | protected String[] getParameterTagAndValue(int paramIndex) throws SQLException(Code) | | Return a stored parameter tag and value.
Parameters: paramIndex - the index into the inString a the parameter tag and the parameter value exception: SQLException - if something goes wrong |
setAsciiStream | public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException(Code) | | 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. JDBC will read the
data from the stream as needed, until it reaches end-of-file. 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.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value Parameters: length - the number of bytes in the stream exception: SQLException - if a database access error occurs |
setBigDecimal | public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException(Code) | | Sets a parameter to a java.lang.BigDecimal value. The driver converts this
to a SQL NUMERIC value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setBinaryStream | public void setBinaryStream(int parameterIndex, InputStream inStreamArg, int length) throws SQLException(Code) | | Stores a binary stream into parameters array, using an intermediate byte[].
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. JDBC will read
the data from the stream as needed, until it reaches end-of-file. This
should be more or less equivalent to setBytes(blob.getBytes()).
Note: This stream object can either be a standard Java stream
object or your own subclass that implements the standard interface.
Parameters: parameterIndex - the first parameter is 1... Parameters: inStreamArg - the parameter value Parameters: length - the parameter length exception: SQLException - if a database access error occurs See Also: java.sql.PreparedStatement.setBinaryStream(intjava.io.InputStreamint) |
setBoolean | public void setBoolean(int parameterIndex, boolean x) throws SQLException(Code) | | Sets a parameter to a Java boolean value. The driver converts this to a SQL
BIT value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setByte | public void setByte(int parameterIndex, byte x) throws SQLException(Code) | | Sets a parameter to a Java byte value.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setBytes | public void setBytes(int parameterIndex, byte[] x) throws SQLException(Code) | | Sets a parameter to a Java array of bytes.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setDate | public void setDate(int parameterIndex, java.sql.Date x) throws SQLException(Code) | | Sets a parameter to a java.sql.Date value. The driver converts this to a
SQL DATE value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setDouble | public void setDouble(int parameterIndex, double x) throws SQLException(Code) | | Sets a parameter to a Java double value. The driver converts this to a SQL
DOUBLE value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setFloat | public void setFloat(int parameterIndex, float x) throws SQLException(Code) | | Sets a parameter to a Java float value. The driver converts this to a SQL
FLOAT value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setInt | public void setInt(int parameterIndex, int x) throws SQLException(Code) | | Sets a parameter to a Java int value. The driver converts this to a SQL
INTEGER value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setLong | public void setLong(int parameterIndex, long x) throws SQLException(Code) | | Sets a parameter to a Java long value. The driver converts this to a SQL
BIGINT value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setNull | public void setNull(int parameterIndex, int sqlType) throws SQLException(Code) | | Sets a parameter to SQL NULL.
Parameters: parameterIndex - the first parameter is 1, etc... Parameters: sqlType - the SQL type code defined in java.sql.Types exception: SQLException - if a database access error occurs |
setObject | public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException(Code) | | Sets the value of a parameter using an object; use the
java.lang equivalent objects for integral values.
The given Java object will be converted to the targetSqlType before being
sent to the database.
Note that this method may be used to pass database-specific abstract data
types. This is done by using a Driver-specific Java type and using a
targetSqlType of java.sql.Types.OTHER .
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the object containing the input parameter value Parameters: targetSqlType - The SQL type to be send to the database Parameters: scale - for java.sql.Types.DECIMAL orjava.sql.Types.NUMERIC types this is the number ofdigits after the decimal. For all other types this value will beignored. exception: SQLException - if a database access error or an incompatible typematch occurs See Also: java.sql.PreparedStatement.setObject(intjava.lang.Objectintint) |
setObject | public void setObject(int parameterIndex, Object x) throws SQLException(Code) | | This stores an Object parameter into the parameters array.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the object to set exception: SQLException - if a database access error occurs |
setParameter | protected void setParameter(int paramIndex, String s) throws SQLException(Code) | | Stores a parameter into parameters String array. Called by most setXXX()
methods.
Parameters: paramIndex - the index into the inString Parameters: s - a string to be stored exception: SQLException - if something goes wrong |
setParameterWithTag | void setParameterWithTag(int paramIndex, String typeTag, String param) throws SQLException(Code) | | Stores parameter and its type as a quoted String, so the
controller can decode them back.
We could avoid inlining the arguments and just tag them and send them apart
as an object list. But this would imply a couple of changes elsewhere,
among other: macro-handling, recoverylog,...
Parameters: paramIndex - the index into the inString Parameters: typeTag - type of the parameter Parameters: param - the parameter string to be stored exception: SQLException - if something goes wrong See Also: PreparedStatementSerialization.setPreparedStatement(Stringjava.sql.PreparedStatement) |
setShort | public void setShort(int parameterIndex, short x) throws SQLException(Code) | | Sets a parameter to a Java short value. The driver converts this to a SQL
SMALLINT value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setString | public void setString(int parameterIndex, String x) throws SQLException(Code) | | Sets a parameter to a Java String value. The driver converts this to a SQL
VARCHAR or LONGVARCHAR value (depending on the arguments size relative to
the driver's limits on VARCHARs) when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setTime | public void setTime(int parameterIndex, Time x) throws SQLException(Code) | | Sets a parameter to a java.sql.Time value. The driver
converts this to a SQL TIME value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1...)); Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setTimestamp | public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException(Code) | | Sets a parameter to a java.sql.Timestamp value. The driver
converts this to a SQL TIMESTAMP value when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value exception: SQLException - if a database access error occurs |
setURL | public void setURL(int parameterIndex, java.net.URL x) throws SQLException(Code) | | Sets the designated parameter to the given java.net.URL
value. The driver converts this to an SQL DATALINK value
when it sends it to the database.
Parameters: parameterIndex - the first parameter is 1, the second is 2, ... Parameters: x - the java.net.URL object to be set exception: SQLException - if a database access error occurs since: JDK 1.4 |
setUnicodeStream | public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException(Code) | | 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. JDBC will read the
data from the stream as needed, until it reaches end-of-file. The JDBC
driver will do any necessary conversion from UNICODE to the database char
format.
** DEPRECIATED IN JDBC 2 **
Note: this stream object can either be a standard Java stream
object or your own subclass that implements the standard interface.
Parameters: parameterIndex - the first parameter is 1... Parameters: x - the parameter value Parameters: length - the parameter length exception: SQLException - if a database access error occurs |
toString | public String toString()(Code) | | Returns the SQL statement with the current template values substituted.
Note: : This is identical to compileQuery() except
instead of throwing SQLException if a parameter is null , it
places ? instead.
the SQL statement |
trimStringBuffer | protected String trimStringBuffer()(Code) | | Sets the length of the temporary buffer to zero and returns a trimmed
version of the buffer's content. This ensures that we are not leaking
memory and that we manipulate Strings which have the minimal possible
memory footprint. Useful when handling BLOBs. Please refer to bug #4546734
is Sun's bug database.
a String object containing a trimmed version of the StringBuffer'scontent |
Methods inherited from org.continuent.sequoia.driver.Statement | public synchronized void addBatch(String sql) throws SQLException(Code)(Java Doc) protected void addWarningTo(SQLWarning addMe, SQLWarning toThis)(Code)(Java Doc) public void cancel() throws SQLException(Code)(Java Doc) public void clearBatch() throws SQLException(Code)(Java Doc) public void clearWarnings() throws SQLException(Code)(Java Doc) public void close() throws SQLException(Code)(Java Doc) public boolean execute(String sql) throws SQLException(Code)(Java Doc) protected boolean execute(String sqlSkeleton, String parameters) throws SQLException(Code)(Java Doc) public boolean execute(String sql, int autoGeneratedKeys) throws SQLException(Code)(Java Doc) public boolean execute(String sql, int[] columnIndexes) throws SQLException(Code)(Java Doc) public boolean execute(String sql, String[] columnNames) throws SQLException(Code)(Java Doc) public int[] executeBatch() throws BatchUpdateException(Code)(Java Doc) public java.sql.ResultSet executeQuery(String sql) throws SQLException(Code)(Java Doc) protected java.sql.ResultSet executeQuery(String sqlSkeleton, String parameters) throws SQLException(Code)(Java Doc) public int executeUpdate(String sql) throws SQLException(Code)(Java Doc) public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException(Code)(Java Doc) public int executeUpdate(String sql, int[] columnIndexes) throws SQLException(Code)(Java Doc) public int executeUpdate(String sql, String[] columnNames) throws SQLException(Code)(Java Doc) protected int executeUpdateWithSkeleton(String sqlSkeleton, String parameters) throws SQLException(Code)(Java Doc) protected void finalize() throws Throwable(Code)(Java Doc) public java.sql.Connection getConnection() throws SQLException(Code)(Java Doc) public int getFetchDirection() throws SQLException(Code)(Java Doc) public int getFetchSize() throws SQLException(Code)(Java Doc) public java.sql.ResultSet getGeneratedKeys() throws SQLException(Code)(Java Doc) public int getMaxFieldSize() throws SQLException(Code)(Java Doc) public int getMaxRows() throws SQLException(Code)(Java Doc) public boolean getMoreResults() throws SQLException(Code)(Java Doc) public boolean getMoreResults(int current) throws SQLException(Code)(Java Doc) public int getQueryTimeout() throws SQLException(Code)(Java Doc) public java.sql.ResultSet getResultSet() throws SQLException(Code)(Java Doc) public int getResultSetConcurrency() throws SQLException(Code)(Java Doc) public int getResultSetHoldability() throws SQLException(Code)(Java Doc) public int getResultSetType() throws SQLException(Code)(Java Doc) public int getUpdateCount() throws SQLException(Code)(Java Doc) public SQLWarning getWarnings() throws SQLException(Code)(Java Doc) protected boolean isClosed()(Code)(Java Doc) public void setCursorName(String name) throws SQLException(Code)(Java Doc) public void setEscapeProcessing(boolean enable) throws SQLException(Code)(Java Doc) public void setFetchDirection(int direction) throws SQLException(Code)(Java Doc) public void setFetchSize(int rows) throws SQLException(Code)(Java Doc) public void setMaxFieldSize(int max) throws SQLException(Code)(Java Doc) public void setMaxRows(int max) throws SQLException(Code)(Java Doc) public void setQueryTimeout(int seconds) throws SQLException(Code)(Java Doc) protected void setReadRequestParameters(RequestWithResultSetParameters request)(Code)(Java Doc) public void setResultSetConcurrency(int value) throws SQLException(Code)(Java Doc) public void setResultSetType(int value) throws SQLException(Code)(Java Doc)
|
|
|