Package org.teiid.jdbc
Class StatementImpl
- java.lang.Object
-
- org.teiid.jdbc.WrapperImpl
-
- org.teiid.jdbc.StatementImpl
-
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
,TeiidStatement
- Direct Known Subclasses:
PreparedStatementImpl
public class StatementImpl extends WrapperImpl implements TeiidStatement
-
-
Field Summary
Fields Modifier and Type Field Description protected org.teiid.jdbc.StatementImpl.State
commandStatus
protected long
currentRequestID
static String
NEWINSTANCE
protected static int
NO_TIMEOUT
protected Map<String,Integer>
outParamByName
protected Map<Integer,Integer>
outParamIndexMap
protected long
queryTimeoutMS
protected ResultSetImpl
resultSet
protected int[]
updateCounts
Array of update counts as returned by executeBatch()-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
accumulateWarnings(List<Throwable> serverWarnings)
void
addBatch(String sql)
static ResultsFuture<Boolean>
booleanFuture(boolean isTrue)
void
cancel()
protected void
checkStatement()
This utility method checks if the jdbc statement is closed and throws an exception if it is closed.void
clearBatch()
void
clearWarnings()
void
close()
void
closeOnCompletion()
protected void
copyPropertiesToRequest(RequestMessage res)
Helper method for copy the connection properties to request message.protected RequestMessage
createRequestMessage(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode)
protected void
createResultSet(ResultsMessage resultsMsg)
boolean
execute(String sql)
boolean
execute(String sql, int autoGeneratedKeys)
boolean
execute(String sql, int[] columnIndexes)
boolean
execute(String sql, String[] columnNames)
int[]
executeBatch()
ResultSet
executeQuery(String sql)
protected ResultsFuture<Boolean>
executeSql(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode, boolean synch, RequestOptions options)
protected ResultsFuture<Boolean>
executeSql(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode, boolean synch, RequestOptions options, boolean autoGenerateKeys)
int
executeUpdate(String sql)
int
executeUpdate(String sql, int autoGeneratedKeys)
int
executeUpdate(String sql, int[] columnIndexes)
int
executeUpdate(String sql, String[] columnNames)
Collection<Annotation>
getAnnotations()
Get collection of annotations from the query planner from the last command executed on the StatementConnectionImpl
getConnection()
String
getDebugLog()
Obtain the query planner debug log from the last command executed on this Statement, if it was requested with SHOWPLAN DEBUG.protected DQP
getDQP()
String
getExecutionProperty(String name)
Get the execution property value.int
getFetchDirection()
int
getFetchSize()
ResultSet
getGeneratedKeys()
int
getMaxFieldSize()
int
getMaxRows()
protected ConnectionImpl
getMMConnection()
boolean
getMoreResults()
boolean
getMoreResults(int current)
PlanNode
getPlanDescription()
Obtain the query plan object representation from the last command executed on this Statement, if a query plan was requested in the command.int
getQueryTimeout()
String
getRequestIdentifier()
Get ID for last execution which can be used for matching up executions on the client side with executions in the server logs.ResultSetImpl
getResultSet()
int
getResultSetConcurrency()
int
getResultSetHoldability()
int
getResultSetType()
protected TimeZone
getServerTimeZone()
int
getUpdateCount()
SQLWarning
getWarnings()
protected boolean
hasResultSet()
boolean
isClosed()
boolean
isCloseOnCompletion()
boolean
isPoolable()
protected void
resetExecutionState()
Reset all per-execution state - this should be done before executing a new command.protected void
setAnalysisInfo(ResultsMessage resultsMsg)
void
setCursorName(String name)
void
setEscapeProcessing(boolean enable)
void
setExecutionProperty(String name, String value)
Set the execution property value.void
setFetchDirection(int direction)
void
setFetchSize(int rows)
void
setMaxFieldSize(int max)
void
setMaxRows(int maxRows)
void
setPayload(Serializable payload)
Set the per-statement security payload.void
setPoolable(boolean arg0)
void
setQueryTimeout(int seconds)
ResultsFuture<Boolean>
submitExecute(String sql, RequestOptions options)
void
submitExecute(String sql, StatementCallback callback, RequestOptions options)
Execute the given statement using a non-blocking callback.protected void
timeoutOccurred()
Ends the command and sets the status to TIMED_OUT.-
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.Statement
executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, getLargeUpdateCount, setLargeMaxRows
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Field Detail
-
NEWINSTANCE
public static final String NEWINSTANCE
- See Also:
- Constant Field Values
-
NO_TIMEOUT
protected static final int NO_TIMEOUT
- See Also:
- Constant Field Values
-
commandStatus
protected volatile org.teiid.jdbc.StatementImpl.State commandStatus
-
queryTimeoutMS
protected long queryTimeoutMS
-
currentRequestID
protected long currentRequestID
-
resultSet
protected volatile ResultSetImpl resultSet
-
updateCounts
protected int[] updateCounts
Array of update counts as returned by executeBatch()
-
-
Method Detail
-
getDQP
protected DQP getDQP()
-
getMMConnection
protected ConnectionImpl getMMConnection()
-
getServerTimeZone
protected TimeZone getServerTimeZone() throws SQLException
- Throws:
SQLException
-
resetExecutionState
protected void resetExecutionState() throws SQLException
Reset all per-execution state - this should be done before executing a new command.- Throws:
SQLException
-
addBatch
public void addBatch(String sql) throws SQLException
- Specified by:
addBatch
in interfaceStatement
- Throws:
SQLException
-
cancel
public void cancel() throws SQLException
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException
- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLException
-
clearBatch
public void clearBatch() throws SQLException
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
-
checkStatement
protected void checkStatement() throws TeiidSQLException
This utility method checks if the jdbc statement is closed and throws an exception if it is closed.
- Throws:
TeiidSQLException
- if the statement object is closed.
-
submitExecute
public void submitExecute(String sql, StatementCallback callback, RequestOptions options) throws SQLException
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
- Throws:
SQLException
-
submitExecute
public ResultsFuture<Boolean> submitExecute(String sql, RequestOptions options) throws SQLException
- Throws:
SQLException
-
execute
public boolean execute(String sql) throws SQLException
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
executeBatch
public int[] executeBatch() throws SQLException
- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLException
-
executeQuery
public ResultSet executeQuery(String sql) throws SQLException
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
hasResultSet
protected boolean hasResultSet() throws SQLException
- Throws:
SQLException
-
createResultSet
protected void createResultSet(ResultsMessage resultsMsg) throws SQLException
- Throws:
SQLException
-
executeSql
protected ResultsFuture<Boolean> executeSql(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode, boolean synch, RequestOptions options) throws SQLException
- Throws:
SQLException
-
executeSql
protected ResultsFuture<Boolean> executeSql(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode, boolean synch, RequestOptions options, boolean autoGenerateKeys) throws SQLException
- Throws:
SQLException
-
booleanFuture
public static ResultsFuture<Boolean> booleanFuture(boolean isTrue)
-
createRequestMessage
protected RequestMessage createRequestMessage(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode)
-
getFetchDirection
public int getFetchDirection() throws SQLException
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLException
-
getFetchSize
public int getFetchSize() throws SQLException
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
-
getMaxFieldSize
public int getMaxFieldSize() throws SQLException
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
getMaxRows
public int getMaxRows() throws SQLException
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults() throws SQLException
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws SQLException
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getQueryTimeout
public int getQueryTimeout() throws SQLException
- Specified by:
getQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
getResultSet
public ResultSetImpl getResultSet() throws SQLException
- Specified by:
getResultSet
in interfaceStatement
- Throws:
SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency() throws SQLException
- Specified by:
getResultSetConcurrency
in interfaceStatement
- Throws:
SQLException
-
getResultSetType
public int getResultSetType()
- Specified by:
getResultSetType
in interfaceStatement
-
getUpdateCount
public int getUpdateCount() throws SQLException
- Specified by:
getUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarnings
in interfaceStatement
- Throws:
SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws SQLException
- Specified by:
setEscapeProcessing
in interfaceStatement
- Throws:
SQLException
-
setFetchDirection
public void setFetchDirection(int direction) throws SQLException
- Specified by:
setFetchDirection
in interfaceStatement
- Throws:
SQLException
-
setFetchSize
public void setFetchSize(int rows) throws SQLException
- Specified by:
setFetchSize
in interfaceStatement
- Throws:
SQLException
-
setMaxRows
public void setMaxRows(int maxRows) throws SQLException
- Specified by:
setMaxRows
in interfaceStatement
- Throws:
SQLException
-
setQueryTimeout
public void setQueryTimeout(int seconds) throws SQLException
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
copyPropertiesToRequest
protected void copyPropertiesToRequest(RequestMessage res) throws TeiidSQLException
Helper method for copy the connection properties to request message.- Parameters:
res
- Request message that these properties to be copied to.- Throws:
TeiidSQLException
-
timeoutOccurred
protected void timeoutOccurred()
Ends the command and sets the status to TIMED_OUT.
-
setPayload
public void setPayload(Serializable payload)
Description copied from interface:TeiidStatement
Set the per-statement security payload. This optional payload will accompany each request to the data source(s) so that the connector will have access to it.To remove an existing payload from a statement, call this method with a
null
argument.- Specified by:
setPayload
in interfaceTeiidStatement
- Parameters:
payload
- The payload that is to accompany requests executed from this statement.
-
setExecutionProperty
public void setExecutionProperty(String name, String value)
Description copied from interface:TeiidStatement
Set the execution property value.- Specified by:
setExecutionProperty
in interfaceTeiidStatement
- Parameters:
name
- Execution property namevalue
- Execution property value
-
getExecutionProperty
public String getExecutionProperty(String name)
Description copied from interface:TeiidStatement
Get the execution property value.- Specified by:
getExecutionProperty
in interfaceTeiidStatement
- Parameters:
name
- Execution property name- Returns:
- Execution property value or null if not set
-
getPlanDescription
public PlanNode getPlanDescription()
Description copied from interface:TeiidStatement
Obtain the query plan object representation from the last command executed on this Statement, if a query plan was requested in the command. If no plan was requested, this method will return null.- Specified by:
getPlanDescription
in interfaceTeiidStatement
- Returns:
- PlanNode representing the root of the query plan
-
getDebugLog
public String getDebugLog()
Description copied from interface:TeiidStatement
Obtain the query planner debug log from the last command executed on this Statement, if it was requested with SHOWPLAN DEBUG. If no debug output was requested, this method will return null.- Specified by:
getDebugLog
in interfaceTeiidStatement
- Returns:
- Debug log or null if no log exists
-
getAnnotations
public Collection<Annotation> getAnnotations()
Description copied from interface:TeiidStatement
Get collection of annotations from the query planner from the last command executed on the Statement- Specified by:
getAnnotations
in interfaceTeiidStatement
- Returns:
- Collection of
Annotation
s, may return null
-
getRequestIdentifier
public String getRequestIdentifier()
Description copied from interface:TeiidStatement
Get ID for last execution which can be used for matching up executions on the client side with executions in the server logs.- Specified by:
getRequestIdentifier
in interfaceTeiidStatement
- Returns:
- String identifier for the last execution
-
setAnalysisInfo
protected void setAnalysisInfo(ResultsMessage resultsMsg)
-
isPoolable
public boolean isPoolable() throws SQLException
- Specified by:
isPoolable
in interfaceStatement
- Throws:
SQLException
-
setPoolable
public void setPoolable(boolean arg0) throws SQLException
- Specified by:
setPoolable
in interfaceStatement
- Throws:
SQLException
-
getConnection
public ConnectionImpl getConnection() throws SQLException
- Specified by:
getConnection
in interfaceStatement
- Throws:
SQLException
-
execute
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
public boolean execute(String sql, int[] columnIndexes) throws SQLException
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
public boolean execute(String sql, String[] columnNames) throws SQLException
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, String[] columnNames) throws SQLException
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLException
- Specified by:
getGeneratedKeys
in interfaceStatement
- Throws:
SQLException
-
getResultSetHoldability
public int getResultSetHoldability() throws SQLException
- Specified by:
getResultSetHoldability
in interfaceStatement
- Throws:
SQLException
-
setCursorName
public void setCursorName(String name) throws SQLException
- Specified by:
setCursorName
in interfaceStatement
- Throws:
SQLException
-
setMaxFieldSize
public void setMaxFieldSize(int max) throws SQLException
- Specified by:
setMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
closeOnCompletion
public void closeOnCompletion() throws SQLException
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws SQLException
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
-