Package org.apache.calcite.avatica
Class AvaticaStatement
java.lang.Object
org.apache.calcite.avatica.AvaticaStatement
- All Implemented Interfaces:
AutoCloseable,Statement,Wrapper
- Direct Known Subclasses:
AvaticaPreparedStatement
Implementation of
Statement
for the Avatica engine.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanSupport forcancel()method.protected booleanprotected booleanSupport forcloseOnCompletion()method.final AvaticaConnectionstatic final intThe default value forStatement.getFetchSize().Statement id; unique within connection.protected longprotected AvaticaResultSetCurrent result set, or null if the statement is not executing anything.protected longCurrent update count.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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAvaticaStatement(AvaticaConnection connection, Meta.StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) Creates an AvaticaStatement.protectedAvaticaStatement(AvaticaConnection connection, Meta.StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability, Meta.Signature signature) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcancel()protected voidvoidvoidvoidclose()protected voidclose_()voidbooleanbooleanbooleanbooleanint[]protected long[]Executes a collection of updates in a single batch RPC.protected voidexecuteInternal(String sql) protected booleanexecuteInternal(Meta.Signature signature, boolean isUpdate) Executes a prepared statement.long[]longexecuteLargeUpdate(String sql) executeQuery(String sql) protected ResultSetexecuteQueryInternal(Meta.Signature signature, boolean isUpdate) Executes a prepared query, closing any previously open result set.final intexecuteUpdate(String sql) intexecuteUpdate(String sql, int autoGeneratedKeys) intexecuteUpdate(String sql, int[] columnIndexes) intexecuteUpdate(String sql, String[] columnNames) protected List<TypedValue>Returns a list of bound parameter values.intintintgetId()Returns the identifier of the statement, unique within its connection.longlongintfinal intbooleanbooleangetMoreResults(int current) protected List<TypedValue>Returns the list of values of this statement's parameters.intintintintprotected Meta.SignatureintbooleanisClosed()booleanbooleanbooleanisWrapperFor(Class<?> iface) protected voidvoidsetCursorName(String name) voidsetEscapeProcessing(boolean enable) voidsetFetchDirection(int direction) voidsetFetchSize(int rows) voidsetLargeMaxRows(long maxRowCount) voidsetMaxFieldSize(int max) final voidsetMaxRows(int maxRowCount) voidsetPoolable(boolean poolable) voidsetQueryTimeout(int seconds) protected voidsetSignature(Meta.Signature signature) protected booleansyncResults(QueryState state, long offset) Re-initialize the ResultSet on the server with the given state.<T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, isSimpleIdentifier
-
Field Details
-
DEFAULT_FETCH_SIZE
public static final int DEFAULT_FETCH_SIZEThe default value forStatement.getFetchSize().- See Also:
-
connection
-
handle
Statement id; unique within connection. -
closed
protected boolean closed -
cancelFlag
Support forcancel()method. -
closeOnCompletion
protected boolean closeOnCompletionSupport forcloseOnCompletion()method. -
openResultSet
Current result set, or null if the statement is not executing anything. Any method which modifies this member must synchronize on the AvaticaStatement. -
updateCount
protected long updateCountCurrent update count. Same lifecycle asopenResultSet. -
maxRowCount
protected long maxRowCount
-
-
Constructor Details
-
AvaticaStatement
protected AvaticaStatement(AvaticaConnection connection, Meta.StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) Creates an AvaticaStatement.- Parameters:
connection- Connectionh- Statement handleresultSetType- Result set typeresultSetConcurrency- Result set concurrencyresultSetHoldability- Result set holdability
-
AvaticaStatement
protected AvaticaStatement(AvaticaConnection connection, Meta.StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability, Meta.Signature signature)
-
-
Method Details
-
setSignature
-
getSignature
-
getStatementType
-
getId
public int getId()Returns the identifier of the statement, unique within its connection. -
checkOpen
- Throws:
SQLException
-
executeInternal
- Throws:
SQLException
-
executeBatchInternal
Executes a collection of updates in a single batch RPC.- Returns:
- an array of long mapping to the update count per SQL command.
- Throws:
SQLException
-
resetStatement
protected void resetStatement() -
syncResults
Re-initialize the ResultSet on the server with the given state.- Parameters:
state- The ResultSet's state.offset- Offset into the desired ResultSet- Returns:
- True if the ResultSet has more results, false if there are no more results.
- Throws:
NoSuchStatementException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
executeQuery
- Specified by:
executeQueryin interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLException
-
close_
protected void close_() -
getMaxFieldSize
- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLException
-
setMaxFieldSize
- Specified by:
setMaxFieldSizein interfaceStatement- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLException
-
getLargeMaxRows
- Specified by:
getLargeMaxRowsin interfaceStatement- Throws:
SQLException
-
setMaxRows
- Specified by:
setMaxRowsin interfaceStatement- Throws:
SQLException
-
setLargeMaxRows
- Specified by:
setLargeMaxRowsin interfaceStatement- Throws:
SQLException
-
setEscapeProcessing
- Specified by:
setEscapeProcessingin interfaceStatement- Throws:
SQLException
-
getQueryTimeout
- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeoutin interfaceStatement- Throws:
SQLException
-
cancel
- Specified by:
cancelin interfaceStatement- Throws:
SQLException
-
getWarnings
- Specified by:
getWarningsin interfaceStatement- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException
-
setCursorName
- Specified by:
setCursorNamein interfaceStatement- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSetin interfaceStatement- Throws:
SQLException
-
getUpdateCount
- Specified by:
getUpdateCountin interfaceStatement- Throws:
SQLException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCountin interfaceStatement- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
setFetchDirection
- Specified by:
setFetchDirectionin interfaceStatement- Throws:
SQLException
-
getFetchDirection
- Specified by:
getFetchDirectionin interfaceStatement- Throws:
SQLException
-
setFetchSize
- Specified by:
setFetchSizein interfaceStatement- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLException
-
getResultSetType
- Specified by:
getResultSetTypein interfaceStatement- Throws:
SQLException
-
addBatch
- Specified by:
addBatchin interfaceStatement- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatchin interfaceStatement- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatchin interfaceStatement- Throws:
SQLException
-
executeLargeBatch
- Specified by:
executeLargeBatchin interfaceStatement- Throws:
SQLException
-
getConnection
- Specified by:
getConnectionin interfaceStatement- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
getGeneratedKeys
- Specified by:
getGeneratedKeysin interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
getResultSetHoldability
- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
isClosed
- Specified by:
isClosedin interfaceStatement- Throws:
SQLException
-
setPoolable
- Specified by:
setPoolablein interfaceStatement- Throws:
SQLException
-
isPoolable
- Specified by:
isPoolablein interfaceStatement- Throws:
SQLException
-
closeOnCompletion
- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
executeInternal
Executes a prepared statement.- Parameters:
signature- Parsed statementisUpdate- if the execute is for an update- Returns:
- as specified by
Statement.execute(String) - Throws:
SQLException- if a database error occurs
-
executeQueryInternal
protected ResultSet executeQueryInternal(Meta.Signature signature, boolean isUpdate) throws SQLException Executes a prepared query, closing any previously open result set.- Parameters:
signature- Parsed queryisUpdate- If the execute is for an update- Returns:
- Result set
- Throws:
SQLException- if a database error occurs
-
getParameterValues
Returns the list of values of this statement's parameters.Called at execute time. Not a public API.
The default implementation returns the empty list, because non-prepared statements have no parameters.
-
getBoundParameterValues
Returns a list of bound parameter values.If any of the parameters have not been bound, throws. If parameters have been bound to null, the value in the list is null.
- Throws:
SQLException
-