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.StatecommandStatusprotected longcurrentRequestIDstatic StringNEWINSTANCEprotected static intNO_TIMEOUTprotected Map<String,Integer>outParamByNameprotected Map<Integer,Integer>outParamIndexMapprotected longqueryTimeoutMSprotected ResultSetImplresultSetprotected int[]updateCountsArray 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 voidaccumulateWarnings(List<Throwable> serverWarnings)voidaddBatch(String sql)static ResultsFuture<Boolean>booleanFuture(boolean isTrue)voidcancel()protected voidcheckStatement()This utility method checks if the jdbc statement is closed and throws an exception if it is closed.voidclearBatch()voidclearWarnings()voidclose()voidcloseOnCompletion()protected voidcopyPropertiesToRequest(RequestMessage res)Helper method for copy the connection properties to request message.protected RequestMessagecreateRequestMessage(String[] commands, boolean isBatchedCommand, RequestMessage.ResultsMode resultsMode)protected voidcreateResultSet(ResultsMessage resultsMsg)booleanexecute(String sql)booleanexecute(String sql, int autoGeneratedKeys)booleanexecute(String sql, int[] columnIndexes)booleanexecute(String sql, String[] columnNames)int[]executeBatch()ResultSetexecuteQuery(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)intexecuteUpdate(String sql)intexecuteUpdate(String sql, int autoGeneratedKeys)intexecuteUpdate(String sql, int[] columnIndexes)intexecuteUpdate(String sql, String[] columnNames)Collection<Annotation>getAnnotations()Get collection of annotations from the query planner from the last command executed on the StatementConnectionImplgetConnection()StringgetDebugLog()Obtain the query planner debug log from the last command executed on this Statement, if it was requested with SHOWPLAN DEBUG.protected DQPgetDQP()StringgetExecutionProperty(String name)Get the execution property value.intgetFetchDirection()intgetFetchSize()ResultSetgetGeneratedKeys()intgetMaxFieldSize()intgetMaxRows()protected ConnectionImplgetMMConnection()booleangetMoreResults()booleangetMoreResults(int current)PlanNodegetPlanDescription()Obtain the query plan object representation from the last command executed on this Statement, if a query plan was requested in the command.intgetQueryTimeout()StringgetRequestIdentifier()Get ID for last execution which can be used for matching up executions on the client side with executions in the server logs.ResultSetImplgetResultSet()intgetResultSetConcurrency()intgetResultSetHoldability()intgetResultSetType()protected TimeZonegetServerTimeZone()intgetUpdateCount()SQLWarninggetWarnings()protected booleanhasResultSet()booleanisClosed()booleanisCloseOnCompletion()booleanisPoolable()protected voidresetExecutionState()Reset all per-execution state - this should be done before executing a new command.protected voidsetAnalysisInfo(ResultsMessage resultsMsg)voidsetCursorName(String name)voidsetEscapeProcessing(boolean enable)voidsetExecutionProperty(String name, String value)Set the execution property value.voidsetFetchDirection(int direction)voidsetFetchSize(int rows)voidsetMaxFieldSize(int max)voidsetMaxRows(int maxRows)voidsetPayload(Serializable payload)Set the per-statement security payload.voidsetPoolable(boolean arg0)voidsetQueryTimeout(int seconds)ResultsFuture<Boolean>submitExecute(String sql, RequestOptions options)voidsubmitExecute(String sql, StatementCallback callback, RequestOptions options)Execute the given statement using a non-blocking callback.protected voidtimeoutOccurred()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 SQLExceptionReset 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:
addBatchin interfaceStatement- Throws:
SQLException
-
cancel
public void cancel() throws SQLException- Specified by:
cancelin interfaceStatement- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException
-
clearBatch
public void clearBatch() throws SQLException- Specified by:
clearBatchin interfaceStatement- Throws:
SQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLException
-
checkStatement
protected void checkStatement() throws TeiidSQLExceptionThis 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:TeiidStatementExecute 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:
submitExecutein 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:
executein interfaceStatement- Throws:
SQLException
-
executeBatch
public int[] executeBatch() throws SQLException- Specified by:
executeBatchin interfaceStatement- Throws:
SQLException
-
executeQuery
public ResultSet executeQuery(String sql) throws SQLException
- Specified by:
executeQueryin interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException
- Specified by:
executeUpdatein 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:
getFetchDirectionin interfaceStatement- Throws:
SQLException
-
getFetchSize
public int getFetchSize() throws SQLException- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLException
-
getMaxFieldSize
public int getMaxFieldSize() throws SQLException- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLException
-
getMaxRows
public int getMaxRows() throws SQLException- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults() throws SQLException- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws SQLException- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
getQueryTimeout
public int getQueryTimeout() throws SQLException- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLException
-
getResultSet
public ResultSetImpl getResultSet() throws SQLException
- Specified by:
getResultSetin interfaceStatement- Throws:
SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency() throws SQLException- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLException
-
getResultSetType
public int getResultSetType()
- Specified by:
getResultSetTypein interfaceStatement
-
getUpdateCount
public int getUpdateCount() throws SQLException- Specified by:
getUpdateCountin interfaceStatement- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarningsin interfaceStatement- Throws:
SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws SQLException- Specified by:
setEscapeProcessingin interfaceStatement- Throws:
SQLException
-
setFetchDirection
public void setFetchDirection(int direction) throws SQLException- Specified by:
setFetchDirectionin interfaceStatement- Throws:
SQLException
-
setFetchSize
public void setFetchSize(int rows) throws SQLException- Specified by:
setFetchSizein interfaceStatement- Throws:
SQLException
-
setMaxRows
public void setMaxRows(int maxRows) throws SQLException- Specified by:
setMaxRowsin interfaceStatement- Throws:
SQLException
-
setQueryTimeout
public void setQueryTimeout(int seconds) throws SQLException- Specified by:
setQueryTimeoutin 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:TeiidStatementSet 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
nullargument.- Specified by:
setPayloadin 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:TeiidStatementSet the execution property value.- Specified by:
setExecutionPropertyin interfaceTeiidStatement- Parameters:
name- Execution property namevalue- Execution property value
-
getExecutionProperty
public String getExecutionProperty(String name)
Description copied from interface:TeiidStatementGet the execution property value.- Specified by:
getExecutionPropertyin interfaceTeiidStatement- Parameters:
name- Execution property name- Returns:
- Execution property value or null if not set
-
getPlanDescription
public PlanNode getPlanDescription()
Description copied from interface:TeiidStatementObtain 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:
getPlanDescriptionin interfaceTeiidStatement- Returns:
- PlanNode representing the root of the query plan
-
getDebugLog
public String getDebugLog()
Description copied from interface:TeiidStatementObtain 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:
getDebugLogin interfaceTeiidStatement- Returns:
- Debug log or null if no log exists
-
getAnnotations
public Collection<Annotation> getAnnotations()
Description copied from interface:TeiidStatementGet collection of annotations from the query planner from the last command executed on the Statement- Specified by:
getAnnotationsin interfaceTeiidStatement- Returns:
- Collection of
Annotations, may return null
-
getRequestIdentifier
public String getRequestIdentifier()
Description copied from interface:TeiidStatementGet ID for last execution which can be used for matching up executions on the client side with executions in the server logs.- Specified by:
getRequestIdentifierin interfaceTeiidStatement- Returns:
- String identifier for the last execution
-
setAnalysisInfo
protected void setAnalysisInfo(ResultsMessage resultsMsg)
-
isPoolable
public boolean isPoolable() throws SQLException- Specified by:
isPoolablein interfaceStatement- Throws:
SQLException
-
setPoolable
public void setPoolable(boolean arg0) throws SQLException- Specified by:
setPoolablein interfaceStatement- Throws:
SQLException
-
getConnection
public ConnectionImpl getConnection() throws SQLException
- Specified by:
getConnectionin interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql, int[] columnIndexes) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql, String[] columnNames) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, String[] columnNames) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLException
- Specified by:
getGeneratedKeysin interfaceStatement- Throws:
SQLException
-
getResultSetHoldability
public int getResultSetHoldability() throws SQLException- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
setCursorName
public void setCursorName(String name) throws SQLException
- Specified by:
setCursorNamein interfaceStatement- Throws:
SQLException
-
setMaxFieldSize
public void setMaxFieldSize(int max) throws SQLException- Specified by:
setMaxFieldSizein interfaceStatement- Throws:
SQLException
-
closeOnCompletion
public void closeOnCompletion() throws SQLException- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws SQLException- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-
-