Documentation of 'org.apache.derby.impl.sql.GenericPreparedStatement' Java class
GenericPreparedStatement
org.apache.derby.impl.sql

Class GenericPreparedStatement

  • All Implemented Interfaces:
    Dependable, Dependent, ExecPreparedStatement, PreparedStatement
    Direct Known Subclasses:
    GenericStorablePreparedStatement


    public class GenericPreparedStatement
    extends java.lang.Object
    implements ExecPreparedStatement
    Basic implementation of prepared statement. relies on implementation of ResultDescription and Statement that are also in this package.

    These are both dependents (of the schema objects and prepared statements they depend on) and providers. Prepared statements that are providers are cursors that end up being used in positioned delete and update statements (at present).

    This is impl with the regular prepared statements; they will never have the cursor info fields set.

    Stored prepared statements extend this implementation

    • Constructor Detail

      • GenericPreparedStatement

        public GenericPreparedStatement(Statement st)
    • Method Detail

      • upToDate

        public boolean upToDate()
                         throws StandardException
        Description copied from interface: PreparedStatement
        Checks whether this PreparedStatement is up to date. A PreparedStatement can become out of date if any of several things happen: A schema used by the statement is dropped A table used by the statement is dropped A table used by the statement, or a column in such a table, is altered in one of several ways: a column is dropped, a privilege is dropped, a constraint is added or dropped, an index is dropped. A view used by the statement is dropped. In general, anything that happened since the plan was generated that might cause the plan to fail, or to generate incorrect results, will cause this method to return FALSE.
        Specified by:
        upToDate in interface PreparedStatement
        Returns:
        TRUE if the PreparedStatement is up to date, FALSE if it is not up to date
        Throws:
        StandardException
      • upToDate

        public boolean upToDate(GeneratedClass gc)
        Check whether this statement is up to date and its generated class is identical to the supplied class object.
        Specified by:
        upToDate in interface ExecPreparedStatement
        Parameters:
        gc - a generated class that must be identical to getActivationClass() for this method to return true
        Returns:
        true if this statement is up to date and its activation class is identical to gc, false otherwise
        See Also:
        ExecPreparedStatement.upToDate(GeneratedClass)
      • executeSubStatement

        public ResultSet executeSubStatement(Activation parent,
                                             Activation activation,
                                             boolean rollbackParentContext,
                                             long timeoutMillis)
                                      throws StandardException
        Description copied from interface: PreparedStatement
        Execute a statement as part of another statement (ithout a nested connection) and return results.

        There is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.

        Specified by:
        executeSubStatement in interface PreparedStatement
        Parameters:
        parent - The activation of the superstatement
        activation - The activation containing all the local state to execute the plan for substatement
        rollbackParentContext - True if in the event of a statement-level exception, the parent context needs to be rolled back, too.
        timeoutMillis - timeout value in milliseconds.
        Returns:
        A ResultSet for a statement. A ResultSet represents the results returned from the statement, if any. Will return NULL if the plan for the PreparedStatement has aged out of cache, or the plan is out of date.
        Throws:
        StandardException - Thrown on failure
        See Also:
        PreparedStatement.executeSubStatement(Activation, Activation, boolean, long)
      • execute

        public ResultSet execute(Activation activation,
                                 boolean forMetaData,
                                 long timeoutMillis)
                          throws StandardException
        Description copied from interface: PreparedStatement
        Execute the PreparedStatement and return results, used for top level statements (not substatements) in a connection.

        There is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.

        Specified by:
        execute in interface PreparedStatement
        Parameters:
        activation - The activation containing all the local state to execute the plan.
        forMetaData - true if this is a meta-data query
        timeoutMillis - timeout value in milliseconds.
        Returns:
        A ResultSet for a statement. A ResultSet represents the results returned from the statement, if any. Will return NULL if the plan for the PreparedStatement has aged out of cache, or the plan is out of date.
        Throws:
        StandardException - Thrown on failure
        See Also:
        PreparedStatement.execute(org.apache.derby.iapi.sql.Activation, boolean, long)
      • getResultDescription

        public ResultDescription getResultDescription()
        Description copied from interface: PreparedStatement
        Get the ResultDescription for the statement. The ResultDescription describes what the results look like: what are the rows and columns?

        This is available here and on the ResultSet so that users can see the shape of the result before they execute.

        Specified by:
        getResultDescription in interface PreparedStatement
        Returns:
        A ResultDescription describing the results.
      • getParameterTypes

        public DataTypeDescriptor[] getParameterTypes()
        Description copied from interface: PreparedStatement
        Get an array of DataTypeDescriptors describing the types of the parameters of this PreparedStatement. The Nth element of the array describes the Nth parameter.
        Specified by:
        getParameterTypes in interface PreparedStatement
        Returns:
        An array of DataTypeDescriptors telling the type, length, precision, scale, etc. of each parameter of this PreparedStatement.
      • getSource

        public java.lang.String getSource()
        Description copied from interface: PreparedStatement
        Return the SQL string that this statement is for.
        Specified by:
        getSource in interface PreparedStatement
        Returns:
        the SQL string this statement is for.
      • setSPSName

        public final void setSPSName(java.lang.String name)
      • getSPSName

        public java.lang.String getSPSName()
        Description copied from interface: PreparedStatement
        Return the SPS Name for this statement.
        Specified by:
        getSPSName in interface PreparedStatement
        Returns:
        the SPS Name for this statement
      • getCompileTimeInMillis

        public long getCompileTimeInMillis()
        Get the total compile time for the associated query in milliseconds. Compile time can be divided into parse, bind, optimize and generate times.
        Specified by:
        getCompileTimeInMillis in interface PreparedStatement
        Returns:
        long The total compile time for the associated query in milliseconds.
      • getParseTimeInMillis

        public long getParseTimeInMillis()
        Get the parse time for the associated query in milliseconds.
        Specified by:
        getParseTimeInMillis in interface PreparedStatement
        Returns:
        long The parse time for the associated query in milliseconds.
      • getBindTimeInMillis

        public long getBindTimeInMillis()
        Get the bind time for the associated query in milliseconds.
        Specified by:
        getBindTimeInMillis in interface PreparedStatement
        Returns:
        long The bind time for the associated query in milliseconds.
      • getOptimizeTimeInMillis

        public long getOptimizeTimeInMillis()
        Get the optimize time for the associated query in milliseconds.
        Specified by:
        getOptimizeTimeInMillis in interface PreparedStatement
        Returns:
        long The optimize time for the associated query in milliseconds.
      • getGenerateTimeInMillis

        public long getGenerateTimeInMillis()
        Get the generate time for the associated query in milliseconds.
        Specified by:
        getGenerateTimeInMillis in interface PreparedStatement
        Returns:
        long The generate time for the associated query in milliseconds.
      • getBeginCompileTimestamp

        public java.sql.Timestamp getBeginCompileTimestamp()
        Get the timestamp for the beginning of compilation
        Specified by:
        getBeginCompileTimestamp in interface PreparedStatement
        Returns:
        Timestamp The timestamp for the beginning of compilation.
      • getEndCompileTimestamp

        public java.sql.Timestamp getEndCompileTimestamp()
        Get the timestamp for the end of compilation
        Specified by:
        getEndCompileTimestamp in interface PreparedStatement
        Returns:
        Timestamp The timestamp for the end of compilation.
      • getConstantAction

        public final ConstantAction getConstantAction()
        Get the Execution constants. This routine is called at Execution time.
        Specified by:
        getConstantAction in interface ExecPreparedStatement
        Returns:
        ConstantAction The big structure enclosing the Execution constants.
      • getSavedObject

        public final java.lang.Object getSavedObject(int objectNum)
        Get the specified saved object.
        Specified by:
        getSavedObject in interface ExecPreparedStatement
        Parameters:
        objectNum - The object to get.
        Returns:
        the requested saved object.
      • getSavedObjects

        public final java.util.List<java.lang.Object> getSavedObjects()
        Get the saved objects.
        Specified by:
        getSavedObjects in interface ExecPreparedStatement
        Returns:
        all the saved objects
      • isValid

        public boolean isValid()
        Check that all of the dependent's dependencies are valid.
        Specified by:
        isValid in interface Dependent
        Returns:
        true if the dependent is currently valid
      • setValid

        public void setValid()
        set this prepared statement to be valid, currently used by GenericTriggerExecutor.
        Specified by:
        setValid in interface ExecPreparedStatement
      • setSPSAction

        public void setSPSAction()
        Indicate this prepared statement is an SPS action, currently used by GenericTriggerExecutor.
        Specified by:
        setSPSAction in interface ExecPreparedStatement
      • makeInvalid

        public void makeInvalid(int action,
                                LanguageConnectionContext lcc)
                         throws StandardException
        Mark the dependent as invalid (due to at least one of its dependencies being invalid).
        Specified by:
        makeInvalid in interface Dependent
        Parameters:
        action - The action causing the invalidation
        lcc - The LanguageConnectionContext
        Throws:
        StandardException - Standard Derby error policy.
      • isPersistent

        public boolean isPersistent()
        Is this dependent persistent? A stored dependency will be required if both the dependent and provider are persistent.
        Specified by:
        isPersistent in interface Dependable
        Returns:
        boolean Whether or not this dependent is persistent.
      • getObjectName

        public java.lang.String getObjectName()
        Return the name of this Dependable. (Useful for errors.)
        Specified by:
        getObjectName in interface Dependable
        Returns:
        String The name of this Dependable..
      • getObjectID

        public UUID getObjectID()
        Get the Dependable's UUID String.
        Specified by:
        getObjectID in interface Dependable
        Returns:
        String The Dependable's UUID String.
      • getClassType

        public java.lang.String getClassType()
        Get the Dependable's class type.
        Specified by:
        getClassType in interface Dependable
        Returns:
        String Classname that this Dependable belongs to.
      • referencesSessionSchema

        public boolean referencesSessionSchema()
        Return true if the query node for this statement references SESSION schema tables/views. This method gets called at the very beginning of the compile phase of any statement. If the statement which needs to be compiled is already found in cache, then there is no need to compile it again except the case when the statement is referencing SESSION schema objects. There is a small window where such a statement might get cached temporarily (a statement referencing SESSION schema object will be removed from the cache after the bind phase is over because that is when we know for sure that the statement is referencing SESSION schema objects.)
        Specified by:
        referencesSessionSchema in interface PreparedStatement
        Returns:
        true if references SESSION schema tables, else false
      • referencesSessionSchema

        public boolean referencesSessionSchema(StatementNode qt)
                                        throws StandardException
        Return true if the QueryTreeNode references SESSION schema tables/views. The return value is also saved in the local field because it will be used by referencesSessionSchema() method. This method gets called when the statement is not found in cache and hence it is getting compiled. At the beginning of compilation for any statement, first we check if the statement's plan already exist in the cache. If not, then we add the statement to the cache and continue with the parsing and binding. At the end of the binding, this method gets called to see if the QueryTreeNode references a SESSION schema object. If it does, then we want to remove it from the cache, since any statements referencing SESSION schema objects should never get cached.
        Returns:
        true if references SESSION schema tables/views, else false
        Throws:
        StandardException
      • getUpdateMode

        public int getUpdateMode()
        the update mode of the cursor
        Specified by:
        getUpdateMode in interface ExecPreparedStatement
        Returns:
        The update mode of the cursor
      • getCursorInfo

        public java.lang.Object getCursorInfo()
        Return the cursor info in a single chunk. Used by StrorablePreparedStatement
        Specified by:
        getCursorInfo in interface ExecPreparedStatement
        Returns:
        Object the cursor info
      • needsSavepoint

        public boolean needsSavepoint()
        Does this statement need a savepoint?
        Specified by:
        needsSavepoint in interface ExecPreparedStatement
        Returns:
        true if this statement needs a savepoint.
      • isAtomic

        public boolean isAtomic()
        Returns whether or not this Statement requires should behave atomically -- i.e. whether a user is permitted to do a commit/rollback during the execution of this statement.
        Specified by:
        isAtomic in interface PreparedStatement
        Returns:
        boolean Whether or not this Statement is atomic
      • setCacheHolder

        public void setCacheHolder(Cacheable cacheHolder)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isStorable

        public boolean isStorable()
      • setRequiredPermissionsList

        public void setRequiredPermissionsList(java.util.List<StatementPermission> requiredPermissionsList)
      • getVersionCounter

        public final long getVersionCounter()
        Description copied from interface: PreparedStatement
        Get the version counter. A change in the value indicates a recompile has happened.
        Specified by:
        getVersionCounter in interface PreparedStatement
        Returns:
        version counter
      • incrementVersionCounter

        public final void incrementVersionCounter()
      • getInitialRowCount

        public long getInitialRowCount(int rsNum,
                                       long currentRowCount)
        Description copied from interface: ExecPreparedStatement
        Get the initial row count of the specified result set. If the initial row count has not yet been set, initialize it with the value of the current row count.
        Specified by:
        getInitialRowCount in interface ExecPreparedStatement
        Parameters:
        rsNum - the result set to get the initial row count for
        currentRowCount - the current row count for the result set
        Returns:
        the row count from the first execution of the result set
        See Also:
        ExecPreparedStatement.getInitialRowCount(int, long)

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.