Package org.apache.derby.iapi.sql

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


    // try to remember the SQL statement in case anybody asks for it
    SQLText = sql;   

    try {
      Activation activation;
      try {
        PreparedStatement preparedStatement = lcc.prepareInternalStatement
            (lcc.getDefaultSchema(), sql, resultSetConcurrency==
                        java.sql.ResultSet.CONCUR_READ_ONLY, false);
        activation =
          preparedStatement.getActivation(lcc, resultSetType ==
                        java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE);
        checkRequiresCallableStatement(activation);
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
       } catch (Throwable t) {
        throw handleException(t);
       }


      // this is for a Statement execution
      activation.setSingleExecution();

      //bug 4838 - save the auto-generated key information in activation. keeping this
      //information in lcc will not work work it can be tampered by a nested trasaction
      if (autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS)
        activation.setAutoGeneratedKeysResultsetInfo(columnIndexes, columnNames);
      return executeStatement(activation, executeQuery, executeUpdate);
    } finally {
        restoreContextStack();
    }
    }
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);
        gc = getActivationClass();
      }

      ac = new GenericActivationHolder(lcc, gc, this, scrollable);

      inUseCount++;
    }
    // DERBY-2689. Close unused activations-- this method should be called
    // when I'm not holding a lock on a prepared statement to avoid
    // deadlock.
    lcc.closeUnusedActivations();

    Activation parentAct = null;
    StatementContext stmctx = lcc.getStatementContext();

    if (stmctx != null) {
      // If not null, parentAct represents one of 1) the activation of a
      // calling statement and this activation corresponds to a statement
View Full Code Here

    public ResultSet executeSubStatement(LanguageConnectionContext lcc,
                     boolean rollbackParentContext,
                     long timeoutMillis)
    throws StandardException
  {
    Activation parent = lcc.getLastActivation();
    Activation a = getActivation(lcc, false);
    a.setSingleExecution();
    lcc.setupSubStatementSessionContext(parent);
    return executeStmt(a, rollbackParentContext, timeoutMillis);
  }
View Full Code Here

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

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

    if (SanityManager.DEBUG) {
View Full Code Here

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

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



        String executingCursorName = a.getCursorName();

         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.elementAt(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.elementAt(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.elementAt(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.elementAt(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.elementAt(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

        // 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.elementAt(i);
        a.reset();
        a.close();
      }
                      
      popMe();
    }
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.elementAt(i);
      /*
      ** andClose true means we are here for rollback.
      ** In case of rollback, we don't care for holding
      ** cursors and that's why I am resetting holdability
      ** to false for all activations just before rollback
      */ 
      if (andClose)
        a.setResultSetHoldability(false);

      /*
      ** 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;
      }

      a.reset();

      // Only invalidate statements if we performed DDL.
      if (andClose && dataDictionaryInWriteMode()) {
        ExecPreparedStatement ps = a.getPreparedStatement();
        if (ps != null) {
          ps.makeInvalid(DependencyManager.ROLLBACK, this);
        }
      }
    }
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.