Package org.apache.derby.iapi.sql

Examples of org.apache.derby.iapi.sql.Activation


                // closing one or more activation leaving our index beyond
                // the end of the array
                if (i >= acts.size())
                    continue;

                Activation a1 = (Activation) acts.get(i);
                if (!a1.isInUse()) {
                    a1.close();
                }
            }
        }

        if (SanityManager.DEBUG) {
View Full Code Here


        if (size > 0)
        {
            int cursorHash = cursorName.hashCode();

            for (int i = 0; i < size; i++) {
                 Activation a = (Activation) acts.get(i);

                 if (!a.isInUse())
                 {
                    continue;
                 }



                String executingCursorName = a.getCursorName();

                // If the executing cursor has no name, or if the hash code of
                // its name is different from the one we're looking for, it
                // can't possibly match. Since java.lang.String caches the
                // hash code (at least in the most common implementations),
                // checking the hash code is cheaper than comparing the names
                // with java.lang.String.equals(), especially if there are many
                // open statements associated with the connection. See
                // DERBY-3882. Note that we can only use the hash codes to
                // determine that the names don't match. Even if the hash codes
                // are equal, we still need to call equals() to verify that the
                // two names actually are equal.
                if (executingCursorName == null ||
                        executingCursorName.hashCode() != cursorHash) {
                    continue;
                }

                 if (cursorName.equals(executingCursorName)) {

                    ResultSet rs = a.getResultSet();
                    if (rs == null)
                        continue;

                     // if the result set is closed, the the cursor doesn't exist
                     if (rs.isClosed()) {                  
View Full Code Here

     */
    private boolean checkIfAnyActivationHasHoldCursor(String tableName)
            throws StandardException
    {
        for (int i = acts.size() - 1; i >= 0; i--) {
            Activation a = (Activation) acts.get(i);
            if (a.checkIfThisActivationHasHoldCursor(tableName))
                return true;
    }
    return false;
    }
View Full Code Here

        boolean seenOpenResultSets = false;

        /* For every activation */
        for (int i = acts.size() - 1; i >= 0; i--) {

            Activation a = (Activation) acts.get(i);

            if (SanityManager.DEBUG)
            {
                SanityManager.ASSERT(a instanceof CursorActivation, "a is not a CursorActivation");
            }

            if (!a.isInUse())
            {
                continue;
            }

            if (!a.getResultSetHoldability())
            {
                continue;
            }

            ResultSet rs = ((CursorActivation) a).getResultSet();

            /* is there an open result set? */
            if ((rs != null) && !rs.isClosed() && rs.returnsRows())
            {
                seenOpenResultSets = true;
                break;
            }
        }

        if (!seenOpenResultSets)
            return(true);

        // There may be open ResultSet's that are yet to be garbage collected
        // let's try and force these out rather than throw an error
        System.gc();
        System.runFinalization();


        /* For every activation */
        for (int i = acts.size() - 1; i >= 0; i--) {
               
            Activation a = (Activation) acts.get(i);

            if (SanityManager.DEBUG)
            {
                SanityManager.ASSERT(a instanceof CursorActivation, "a is not a CursorActivation");
            }

            if (!a.isInUse())
            {
                continue;
            }

            if (!a.getResultSetHoldability())
            {
                continue;
            }

            ResultSet rs = ((CursorActivation) a).getResultSet();
View Full Code Here

        // synchronize on acts as other threads may be closing activations
        // in this list, thus invalidating the Enumeration
        for (int i = acts.size() - 1; i >= 0; i--) {
               
            Activation a = (Activation) acts.get(i);

            if (!a.isInUse())
            {
                continue;
            }
           
            /* for this prepared statement */
            if (pStmt == a.getPreparedStatement()) {
                ResultSet rs = a.getResultSet();

                /* is there an open result set? */
                if (rs != null && ! rs.isClosed())
                {
                    if (!rs.returnsRows())
                        continue;
                    seenOpenResultSets = true;
                    break;
                }
               
            }
        }

        if (!seenOpenResultSets)
            return false;

        // There may be open ResultSet's that are yet to be garbage collected
        // let's try and force these out rather than throw an error
        System.gc();
        System.runFinalization();


        /* For every activation */
        // synchronize on acts as other threads may be closing activations
        // in this list, thus invalidating the Enumeration
        for (int i = acts.size() - 1; i >= 0; i--) {
               
            Activation a = (Activation) acts.get(i);

            if (!a.isInUse())
            {
                continue;
            }

            /* for this prepared statement */
            if (pStmt == a.getPreparedStatement()) {
                ResultSet rs = a.getResultSet();

                /* is there an open result set? */
                if (rs != null && ! rs.isClosed())
                {
                    if ((provider != null) && rs.returnsRows()) {
View Full Code Here

     *      String schemaName)
     */
    public void resetSchemaUsages(Activation activation, String schemaName)
            throws StandardException {

        Activation parent = activation.getParentActivation();
        SchemaDescriptor defaultSchema = getInitialDefaultSchemaDescriptor();

        // walk SQL session context chain
        while (parent != null) {
            SQLSessionContext ssc = parent.getSQLSessionContextForChildren();
            SchemaDescriptor s = ssc.getDefaultSchema();

            if (SanityManager.DEBUG) {
                SanityManager.ASSERT(s != null, "s should not be empty here");
            }

            if (schemaName.equals(s.getSchemaName())) {
                ssc.setDefaultSchema(defaultSchema);
            }
            parent = parent.getParentActivation();
        }

        // finally top level
        SQLSessionContext top = getTopLevelSQLSessionContext();
        SchemaDescriptor sd = top.getDefaultSchema();
View Full Code Here

                // it maybe the case that a reset()/close() ends up closing
                // one or more activation leaving our index beyond
                // the end of the array
                if (i >= acts.size())
                    continue;
                Activation a = (Activation) acts.get(i);
                a.reset();
                a.close();
            }
                      
            popMe();

            InterruptStatus.saveInfoFromLcc(this);
View Full Code Here

            // one or more activation leaving our index beyond
            // the end of the array
            if (i >= acts.size())
                continue;

            Activation a = (Activation) acts.get(i);
            /*
            ** Look for stale activations.  Activations are
            ** marked as unused during statement finalization.
            ** Here, we sweep and remove this inactive ones.
            */ 
            if (!a.isInUse())
            {
                a.close();
                continue;
            }

            //Determine if the activation has a resultset and if that resultset
            //returns rows. For such an activation, we need to take special
            //actions during commit and rollback as explained in the comments
            //below.
            ResultSet activationResultSet = a.getResultSet();
            boolean resultsetReturnsRows = 
                (activationResultSet != null) && activationResultSet.returnsRows(); ;

            if (forRollback) {
                if (resultsetReturnsRows)
                    //Since we are dealing with rollback, we need to reset
                    //the activation no matter what the holdability might
                    //be provided that resultset returns rows. An example
                    //where we do not want to close a resultset that does
                    //not return rows would be a java procedure which has
                    //user invoked rollback inside of it. That rollback
                    //should not reset the activation associated with
                    //the call to java procedure because that activation
                    //is still being used.
                    a.reset();
                // Only invalidate statements if we performed DDL.
                if (dataDictionaryInWriteMode()) {
                    ExecPreparedStatement ps = a.getPreparedStatement();
                    if (ps != null) {
                        ps.makeInvalid(DependencyManager.ROLLBACK, this);
                    }
                }
            } else {
                //We are dealing with commit here.
                if (resultsetReturnsRows){
                    if (a.getResultSetHoldability() == false)
                        //Close result sets that return rows and are not held
                        //across commit. This is to implement closing JDBC
                        //result sets that are CLOSE_CURSOR_ON_COMMIT at commit
                        //time.
                        activationResultSet.close();
                    else
                        //Clear the current row of the result sets that return
                        //rows and are held across commit. This is to implement
                        //keeping JDBC result sets open that are
                        //HOLD_CURSORS_OVER_COMMIT at commit time and marking
                        //the resultset to be not on a valid row position. The
                        //user will need to reposition within the resultset
                        //before doing any row operations.
                        activationResultSet.clearCurrentRow();                         
                }
                a.clearHeapConglomerateController();
            }
        }
    }
View Full Code Here

     * @param activation the activation
     */
    private SQLSessionContext getCurrentSQLSessionContext(Activation activation) {
        SQLSessionContext curr;

        Activation parent = activation.getParentActivation();

        if (parent == null ) {
            // top level
            curr = getTopLevelSQLSessionContext();
        } else {
            // inside a nested connection (stored procedure/function), or when
            // executing a substatement the SQL session context is maintained
            // in the activation of the parent
            curr = parent.getSQLSessionContextForChildren();
        }

        return curr;
    }
View Full Code Here

   */
  public Activation getActivation(LanguageConnectionContext lcc,
                  boolean scrollable)
    throws StandardException
  {
    Activation ac;
    synchronized (this) {
      GeneratedClass gc = getActivationClass();

      if (gc == null) {
        rePrepare(lcc);
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.Activation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.