Class PreparedStatementImpl
- java.lang.Object
-
- org.teiid.jdbc.WrapperImpl
-
- org.teiid.jdbc.StatementImpl
-
- org.teiid.jdbc.PreparedStatementImpl
-
- All Implemented Interfaces:
AutoCloseable
,PreparedStatement
,Statement
,Wrapper
,TeiidPreparedStatement
,TeiidStatement
- Direct Known Subclasses:
CallableStatementImpl
public class PreparedStatementImpl extends StatementImpl implements TeiidPreparedStatement
Instances of PreparedStatement contain a SQL statement that has already been compiled. The SQL statement contained in a PreparedStatement object may have one or more IN parameters. An IN parameter is a parameter whose value is not specified when a SQL statement is created. Instead the statement has a placeholder for each IN parameter.
The PreparedStatementImpl object wraps the server's PreparedStatement object. The methods in this class are used to set the IN parameters on a server's preparedstatement object.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<List<Object>>
batchParameterList
protected String
prepareSql
-
Fields inherited from class org.teiid.jdbc.StatementImpl
commandStatus, currentRequestID, NEWINSTANCE, NO_TIMEOUT, outParamByName, outParamIndexMap, queryTimeoutMS, resultSet, updateCounts
-
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBatch()
Adds a set of parameters to this PreparedStatement object's list of commands to be sent to the database for execution as a batch.void
addBatch(String sql)
void
clearBatch()
Makes the set of commands in the current batch empty.void
clearParameters()
Clears the values set for the PreparedStatement object's IN parameters and releases the resources used by those values.protected RequestMessage
createRequestMessage(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode)
boolean
execute()
boolean
execute(String sql)
boolean
execute(String sql, int autoGeneratedKeys)
boolean
execute(String sql, int[] columnIndexes)
boolean
execute(String sql, String[] columnNames)
int[]
executeBatch()
ResultSetImpl
executeQuery()
ResultSet
executeQuery(String sql)
int
executeUpdate()
int
executeUpdate(String sql)
int
executeUpdate(String sql, int autoGeneratedKeys)
int
executeUpdate(String sql, int[] columnIndexes)
int
executeUpdate(String sql, String[] columnNames)
ResultSetMetaData
getMetaData()
ParameterMetaDataImpl
getParameterMetaData()
void
setArray(int parameterIndex, Array x)
void
setAsciiStream(int parameterIndex, InputStream x)
void
setAsciiStream(int parameterIndex, InputStream in, int length)
void
setAsciiStream(int parameterIndex, InputStream x, long length)
void
setAutoGeneratedKeys(boolean getAutoGeneratedKeys)
void
setBigDecimal(int parameterIndex, BigDecimal value)
void
setBinaryStream(int parameterIndex, InputStream x)
void
setBinaryStream(int parameterIndex, InputStream in, int length)
void
setBinaryStream(int parameterIndex, InputStream x, long length)
void
setBlob(int parameterIndex, InputStream inputStream)
void
setBlob(int parameterIndex, InputStream inputStream, long length)
void
setBlob(int parameterIndex, Blob x)
void
setBoolean(int parameterIndex, boolean value)
void
setByte(int parameterIndex, byte value)
void
setBytes(int parameterIndex, byte[] bytes)
void
setCharacterStream(int parameterIndex, Reader reader)
void
setCharacterStream(int parameterIndex, Reader reader, int length)
void
setCharacterStream(int parameterIndex, Reader reader, long length)
void
setClob(int parameterIndex, Reader reader)
void
setClob(int parameterIndex, Reader reader, long length)
void
setClob(int parameterIndex, Clob x)
void
setCommand(Object command)
void
setDate(int parameterIndex, Date value)
void
setDate(int parameterIndex, Date x, Calendar cal)
void
setDouble(int parameterIndex, double value)
void
setFloat(int parameterIndex, float value)
void
setInt(int parameterIndex, int value)
void
setLong(int parameterIndex, long value)
void
setNCharacterStream(int parameterIndex, Reader value)
void
setNCharacterStream(int parameterIndex, Reader value, long length)
void
setNClob(int parameterIndex, Reader reader)
void
setNClob(int parameterIndex, Reader reader, long length)
void
setNClob(int parameterIndex, NClob value)
void
setNString(int parameterIndex, String value)
void
setNull(int parameterIndex, int jdbcType)
void
setNull(int parameterIndex, int jdbcType, String typeName)
void
setObject(int parameterIndex, Object value)
void
setObject(int parameterIndex, Object value, int targetJdbcType)
void
setObject(int parameterIndex, Object value, int targetJdbcType, int scale)
void
setRef(int parameterIndex, Ref x)
void
setRowId(int parameterIndex, RowId x)
void
setShort(int parameterIndex, short value)
void
setSQLXML(int parameterIndex, SQLXML xmlObject)
void
setString(int parameterIndex, String value)
void
setTime(int parameterIndex, Time value)
void
setTime(int parameterIndex, Time x, Calendar cal)
void
setTimestamp(int parameterIndex, Timestamp value)
void
setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
void
setUnicodeStream(int parameterIndex, InputStream x, int length)
void
setURL(int parameterIndex, URL x)
void
submitExecute(String sql, StatementCallback callback, RequestOptions options)
Execute the given statement using a non-blocking callback.ResultsFuture<Boolean>
submitExecute(RequestMessage.ResultsMode mode, RequestOptions options)
void
submitExecute(StatementCallback callback, RequestOptions options)
Execute the given statement using a non-blocking callback.-
Methods inherited from class org.teiid.jdbc.StatementImpl
accumulateWarnings, booleanFuture, cancel, checkStatement, clearWarnings, close, closeOnCompletion, copyPropertiesToRequest, createResultSet, executeSql, executeSql, getAnnotations, getConnection, getDebugLog, getDQP, getExecutionProperty, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMMConnection, getMoreResults, getMoreResults, getPlanDescription, getQueryTimeout, getRequestIdentifier, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getServerTimeZone, getUpdateCount, getWarnings, hasResultSet, isClosed, isCloseOnCompletion, isPoolable, resetExecutionState, setAnalysisInfo, setCursorName, setEscapeProcessing, setExecutionProperty, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPayload, setPoolable, setQueryTimeout, submitExecute, timeoutOccurred
-
Methods inherited from class org.teiid.jdbc.WrapperImpl
isWrapperFor, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.PreparedStatement
executeLargeUpdate, setObject, setObject
-
Methods inherited from interface java.sql.Statement
cancel, clearWarnings, close, closeOnCompletion, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Method Detail
-
setAutoGeneratedKeys
public void setAutoGeneratedKeys(boolean getAutoGeneratedKeys)
-
addBatch
public void addBatch() throws SQLException
Adds a set of parameters to this PreparedStatement object's list of commands to be sent to the database for execution as a batch.
- Specified by:
addBatch
in interfacePreparedStatement
- Throws:
SQLException
- if there is an error
-
clearBatch
public void clearBatch() throws SQLException
Makes the set of commands in the current batch empty.- Specified by:
clearBatch
in interfaceStatement
- Overrides:
clearBatch
in classStatementImpl
- Throws:
SQLException
- if a database access error occurs or the driver does not support batch statements
-
clearParameters
public void clearParameters() throws SQLException
Clears the values set for the PreparedStatement object's IN parameters and releases the resources used by those values. In general, parameter values remain in force for repeated use of statement.
- Specified by:
clearParameters
in interfacePreparedStatement
- Throws:
SQLException
- if there is an error while clearing params
-
execute
public boolean execute(String sql) throws SQLException
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classStatementImpl
- Throws:
SQLException
-
submitExecute
public void submitExecute(String sql, StatementCallback callback, RequestOptions options) throws TeiidSQLException
Description copied from interface:TeiidStatement
Execute the given statement using a non-blocking callback. This method is only valid for use with embedded connections. Note that a single Statement may only have 1 asynch query executing at a time.- Specified by:
submitExecute
in interfaceTeiidStatement
- Overrides:
submitExecute
in classStatementImpl
- Throws:
TeiidSQLException
-
executeQuery
public ResultSet executeQuery(String sql) throws SQLException
- Specified by:
executeQuery
in interfaceStatement
- Overrides:
executeQuery
in classStatementImpl
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classStatementImpl
- Throws:
SQLException
-
execute
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classStatementImpl
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classStatementImpl
- Throws:
SQLException
-
execute
public boolean execute(String sql, int[] columnIndexes) throws SQLException
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classStatementImpl
- Throws:
SQLException
-
execute
public boolean execute(String sql, String[] columnNames) throws SQLException
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classStatementImpl
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classStatementImpl
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, String[] columnNames) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classStatementImpl
- Throws:
SQLException
-
addBatch
public void addBatch(String sql) throws SQLException
- Specified by:
addBatch
in interfaceStatement
- Overrides:
addBatch
in classStatementImpl
- Throws:
SQLException
-
submitExecute
public void submitExecute(StatementCallback callback, RequestOptions options) throws SQLException
Description copied from interface:TeiidPreparedStatement
Execute the given statement using a non-blocking callback. This method is only valid for use with embedded connections. Note that a single Statement may only have 1 asynch query executing at a time.- Specified by:
submitExecute
in interfaceTeiidPreparedStatement
- Throws:
SQLException
-
submitExecute
public ResultsFuture<Boolean> submitExecute(RequestMessage.ResultsMode mode, RequestOptions options) throws SQLException
- Throws:
SQLException
-
execute
public boolean execute() throws SQLException
- Specified by:
execute
in interfacePreparedStatement
- Throws:
SQLException
-
executeBatch
public int[] executeBatch() throws SQLException
- Specified by:
executeBatch
in interfaceStatement
- Overrides:
executeBatch
in classStatementImpl
- Throws:
SQLException
-
executeQuery
public ResultSetImpl executeQuery() throws SQLException
- Specified by:
executeQuery
in interfacePreparedStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate() throws SQLException
- Specified by:
executeUpdate
in interfacePreparedStatement
- Throws:
SQLException
-
createRequestMessage
protected RequestMessage createRequestMessage(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode)
- Overrides:
createRequestMessage
in classStatementImpl
-
getMetaData
public ResultSetMetaData getMetaData() throws SQLException
- Specified by:
getMetaData
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream in, int length) throws SQLException
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBigDecimal
public void setBigDecimal(int parameterIndex, BigDecimal value) throws SQLException
- Specified by:
setBigDecimal
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream in, int length) throws SQLException
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, Blob x) throws SQLException
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBoolean
public void setBoolean(int parameterIndex, boolean value) throws SQLException
- Specified by:
setBoolean
in interfacePreparedStatement
- Throws:
SQLException
-
setByte
public void setByte(int parameterIndex, byte value) throws SQLException
- Specified by:
setByte
in interfacePreparedStatement
- Throws:
SQLException
-
setBytes
public void setBytes(int parameterIndex, byte[] bytes) throws SQLException
- Specified by:
setBytes
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Clob x) throws SQLException
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setDate
public void setDate(int parameterIndex, Date value) throws SQLException
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLException
-
setDate
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLException
-
setDouble
public void setDouble(int parameterIndex, double value) throws SQLException
- Specified by:
setDouble
in interfacePreparedStatement
- Throws:
SQLException
-
setFloat
public void setFloat(int parameterIndex, float value) throws SQLException
- Specified by:
setFloat
in interfacePreparedStatement
- Throws:
SQLException
-
setInt
public void setInt(int parameterIndex, int value) throws SQLException
- Specified by:
setInt
in interfacePreparedStatement
- Throws:
SQLException
-
setLong
public void setLong(int parameterIndex, long value) throws SQLException
- Specified by:
setLong
in interfacePreparedStatement
- Throws:
SQLException
-
setNull
public void setNull(int parameterIndex, int jdbcType) throws SQLException
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLException
-
setNull
public void setNull(int parameterIndex, int jdbcType, String typeName) throws SQLException
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object value, int targetJdbcType, int scale) throws SQLException
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object value, int targetJdbcType) throws SQLException
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object value) throws SQLException
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLException
-
setShort
public void setShort(int parameterIndex, short value) throws SQLException
- Specified by:
setShort
in interfacePreparedStatement
- Throws:
SQLException
-
setString
public void setString(int parameterIndex, String value) throws SQLException
- Specified by:
setString
in interfacePreparedStatement
- Throws:
SQLException
-
setTime
public void setTime(int parameterIndex, Time value) throws SQLException
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLException
-
setTime
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, Timestamp value) throws SQLException
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLException
-
setURL
public void setURL(int parameterIndex, URL x) throws SQLException
- Specified by:
setURL
in interfacePreparedStatement
- Throws:
SQLException
-
getParameterMetaData
public ParameterMetaDataImpl getParameterMetaData() throws SQLException
- Specified by:
getParameterMetaData
in interfacePreparedStatement
- Throws:
SQLException
-
setSQLXML
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
- Specified by:
setSQLXML
in interfacePreparedStatement
- Throws:
SQLException
-
setArray
public void setArray(int parameterIndex, Array x) throws SQLException
- Specified by:
setArray
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Reader reader) throws SQLException
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, NClob value) throws SQLException
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, Reader reader) throws SQLException
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNString
public void setNString(int parameterIndex, String value) throws SQLException
- Specified by:
setNString
in interfacePreparedStatement
- Throws:
SQLException
-
setRef
public void setRef(int parameterIndex, Ref x) throws SQLException
- Specified by:
setRef
in interfacePreparedStatement
- Throws:
SQLException
-
setRowId
public void setRowId(int parameterIndex, RowId x) throws SQLException
- Specified by:
setRowId
in interfacePreparedStatement
- Throws:
SQLException
-
setUnicodeStream
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
- Specified by:
setUnicodeStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCommand
public void setCommand(Object command)
-
-