Class AvaticaStatement

    • Field Detail

      • DEFAULT_FETCH_SIZE

        public static final int DEFAULT_FETCH_SIZE
        The default value for Statement.getFetchSize().
        See Also:
        Constant Field Values
      • closed

        protected boolean closed
      • cancelFlag

        protected final java.util.concurrent.atomic.AtomicBoolean cancelFlag
        Support for cancel() method.
      • closeOnCompletion

        protected boolean closeOnCompletion
        Support for closeOnCompletion() method.
      • openResultSet

        protected AvaticaResultSet 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 updateCount
        Current update count. Same lifecycle as openResultSet.
      • queryTimeoutMillis

        private int queryTimeoutMillis
      • resultSetType

        final int resultSetType
      • resultSetConcurrency

        final int resultSetConcurrency
      • resultSetHoldability

        final int resultSetHoldability
      • fetchSize

        private int fetchSize
      • fetchDirection

        private int fetchDirection
      • maxRowCount

        protected long maxRowCount
      • batchedSql

        private final java.util.List<java.lang.String> batchedSql
    • Constructor Detail

      • AvaticaStatement

        protected AvaticaStatement​(AvaticaConnection connection,
                                   Meta.StatementHandle h,
                                   int resultSetType,
                                   int resultSetConcurrency,
                                   int resultSetHoldability)
        Creates an AvaticaStatement.
        Parameters:
        connection - Connection
        h - Statement handle
        resultSetType - Result set type
        resultSetConcurrency - Result set concurrency
        resultSetHoldability - Result set holdability
    • Method Detail

      • setSignature

        protected void setSignature​(Meta.Signature signature)
      • getId

        public int getId()
        Returns the identifier of the statement, unique within its connection.
      • checkOpen

        protected void checkOpen()
                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • checkNotPreparedOrCallable

        private void checkNotPreparedOrCallable​(java.lang.String s)
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeInternal

        protected void executeInternal​(java.lang.String sql)
                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeBatchInternal

        protected long[] executeBatchInternal()
                                       throws java.sql.SQLException
        Executes a collection of updates in a single batch RPC.
        Returns:
        an array of long mapping to the update count per SQL command.
        Throws:
        java.sql.SQLException
      • resetStatement

        protected void resetStatement()
      • syncResults

        protected boolean syncResults​(QueryState state,
                                      long offset)
                               throws NoSuchStatementException
        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

        public boolean execute​(java.lang.String sql)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeQuery

        public java.sql.ResultSet executeQuery​(java.lang.String sql)
                                        throws java.sql.SQLException
        Specified by:
        executeQuery in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public final int executeUpdate​(java.lang.String sql)
                                throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeLargeUpdate

        public long executeLargeUpdate​(java.lang.String sql)
                                throws java.sql.SQLException
        Specified by:
        executeLargeUpdate in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • close

        public void close()
                   throws java.sql.SQLException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • close_

        protected void close_()
      • getMaxFieldSize

        public int getMaxFieldSize()
                            throws java.sql.SQLException
        Specified by:
        getMaxFieldSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setMaxFieldSize

        public void setMaxFieldSize​(int max)
                             throws java.sql.SQLException
        Specified by:
        setMaxFieldSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getMaxRows

        public final int getMaxRows()
                             throws java.sql.SQLException
        Specified by:
        getMaxRows in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getLargeMaxRows

        public long getLargeMaxRows()
                             throws java.sql.SQLException
        Specified by:
        getLargeMaxRows in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setMaxRows

        public final void setMaxRows​(int maxRowCount)
                              throws java.sql.SQLException
        Specified by:
        setMaxRows in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setLargeMaxRows

        public void setLargeMaxRows​(long maxRowCount)
                             throws java.sql.SQLException
        Specified by:
        setLargeMaxRows in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setEscapeProcessing

        public void setEscapeProcessing​(boolean enable)
                                 throws java.sql.SQLException
        Specified by:
        setEscapeProcessing in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getQueryTimeout

        public int getQueryTimeout()
                            throws java.sql.SQLException
        Specified by:
        getQueryTimeout in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getQueryTimeoutMillis

        int getQueryTimeoutMillis()
      • setQueryTimeout

        public void setQueryTimeout​(int seconds)
                             throws java.sql.SQLException
        Specified by:
        setQueryTimeout in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setQueryTimeoutMillis

        void setQueryTimeoutMillis​(int millis)
      • cancel

        public void cancel()
                    throws java.sql.SQLException
        Specified by:
        cancel in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getWarnings

        public java.sql.SQLWarning getWarnings()
                                        throws java.sql.SQLException
        Specified by:
        getWarnings in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • clearWarnings

        public void clearWarnings()
                           throws java.sql.SQLException
        Specified by:
        clearWarnings in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setCursorName

        public void setCursorName​(java.lang.String name)
                           throws java.sql.SQLException
        Specified by:
        setCursorName in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSet

        public java.sql.ResultSet getResultSet()
                                        throws java.sql.SQLException
        Specified by:
        getResultSet in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getUpdateCount

        public int getUpdateCount()
                           throws java.sql.SQLException
        Specified by:
        getUpdateCount in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getLargeUpdateCount

        public long getLargeUpdateCount()
                                 throws java.sql.SQLException
        Specified by:
        getLargeUpdateCount in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getMoreResults

        public boolean getMoreResults()
                               throws java.sql.SQLException
        Specified by:
        getMoreResults in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setFetchDirection

        public void setFetchDirection​(int direction)
                               throws java.sql.SQLException
        Specified by:
        setFetchDirection in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getFetchDirection

        public int getFetchDirection()
                              throws java.sql.SQLException
        Specified by:
        getFetchDirection in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setFetchSize

        public void setFetchSize​(int rows)
                          throws java.sql.SQLException
        Specified by:
        setFetchSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getFetchSize

        public int getFetchSize()
                         throws java.sql.SQLException
        Specified by:
        getFetchSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSetConcurrency

        public int getResultSetConcurrency()
                                    throws java.sql.SQLException
        Specified by:
        getResultSetConcurrency in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSetType

        public int getResultSetType()
                             throws java.sql.SQLException
        Specified by:
        getResultSetType in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • addBatch

        public void addBatch​(java.lang.String sql)
                      throws java.sql.SQLException
        Specified by:
        addBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • clearBatch

        public void clearBatch()
                        throws java.sql.SQLException
        Specified by:
        clearBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeBatch

        public int[] executeBatch()
                           throws java.sql.SQLException
        Specified by:
        executeBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeLargeBatch

        public long[] executeLargeBatch()
                                 throws java.sql.SQLException
        Specified by:
        executeLargeBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getConnection

        public AvaticaConnection getConnection()
                                        throws java.sql.SQLException
        Specified by:
        getConnection in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getMoreResults

        public boolean getMoreResults​(int current)
                               throws java.sql.SQLException
        Specified by:
        getMoreResults in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getGeneratedKeys

        public java.sql.ResultSet getGeneratedKeys()
                                            throws java.sql.SQLException
        Specified by:
        getGeneratedKeys in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 int autoGeneratedKeys)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 int[] columnIndexes)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 java.lang.String[] columnNames)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql,
                               int autoGeneratedKeys)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql,
                               int[] columnIndexes)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql,
                               java.lang.String[] columnNames)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSetHoldability

        public int getResultSetHoldability()
                                    throws java.sql.SQLException
        Specified by:
        getResultSetHoldability in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • isClosed

        public boolean isClosed()
                         throws java.sql.SQLException
        Specified by:
        isClosed in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setPoolable

        public void setPoolable​(boolean poolable)
                         throws java.sql.SQLException
        Specified by:
        setPoolable in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • isPoolable

        public boolean isPoolable()
                           throws java.sql.SQLException
        Specified by:
        isPoolable in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • closeOnCompletion

        public void closeOnCompletion()
                               throws java.sql.SQLException
        Specified by:
        closeOnCompletion in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • isCloseOnCompletion

        public boolean isCloseOnCompletion()
                                    throws java.sql.SQLException
        Specified by:
        isCloseOnCompletion in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • unwrap

        public <T> T unwrap​(java.lang.Class<T> iface)
                     throws java.sql.SQLException
        Specified by:
        unwrap in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • isWrapperFor

        public boolean isWrapperFor​(java.lang.Class<?> iface)
                             throws java.sql.SQLException
        Specified by:
        isWrapperFor in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • executeInternal

        protected boolean executeInternal​(Meta.Signature signature,
                                          boolean isUpdate)
                                   throws java.sql.SQLException
        Executes a prepared statement.
        Parameters:
        signature - Parsed statement
        isUpdate - if the execute is for an update
        Returns:
        as specified by Statement.execute(String)
        Throws:
        java.sql.SQLException - if a database error occurs
      • executeQueryInternal

        protected java.sql.ResultSet executeQueryInternal​(Meta.Signature signature,
                                                          boolean isUpdate)
                                                   throws java.sql.SQLException
        Executes a prepared query, closing any previously open result set.
        Parameters:
        signature - Parsed query
        isUpdate - If the execute is for an update
        Returns:
        Result set
        Throws:
        java.sql.SQLException - if a database error occurs
      • onResultSetClose

        void onResultSetClose​(java.sql.ResultSet resultSet)
        Called by each child result set when it is closed.
        Parameters:
        resultSet - Result set or cell set
      • getParameterValues

        protected java.util.List<TypedValue> 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.

        See Also:
        AvaticaConnection.Trojan.getParameterValues(AvaticaStatement)
      • getBoundParameterValues

        protected java.util.List<TypedValue> getBoundParameterValues()
                                                              throws java.sql.SQLException
        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:
        java.sql.SQLException