Examples of Activation


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==JDBC20Translation.CONCUR_READ_ONLY, false);
        activation =
          preparedStatement.getActivation(lcc, resultSetType == JDBC20Translation.TYPE_SCROLL_INSENSITIVE);
        checkRequiresCallableStatement(activation);
       } 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 == JDBC30Translation.RETURN_GENERATED_KEYS)
        activation.setAutoGeneratedKeysResultsetInfo(columnIndexes, columnNames);
      return executeStatement(activation, executeQuery, executeUpdate);
    } finally {
        restoreContextStack();
    }
    }
View Full Code Here

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

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

    int size = acts.size();
    if (size > 0)
    {
      for (int i = 0; i < size; i++) {
         Activation a = (Activation) acts.get(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

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

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

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

    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

Examples of org.apache.derby.iapi.sql.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 (!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

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

        // 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();
    }
View Full Code Here

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

      // 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

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

                insertSQL.append(") ");
                valuesSQL.append(") ");
                insertSQL.append(valuesSQL);

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

                if (currSC != null) {
                    parentAct = currSC.getActivation();
                }

                // Context used for preparing, don't set any timeout (use 0)
                statementContext = lcc.pushStatementContext(
                        isAtomic,
                        false,
                        insertSQL.toString(),
                        null,
                        false,
                        0L);

                // A priori, the new statement context inherits the activation
                // of the existing statementContext, so that that activation
                // ends up as parent of the new activation 'act' created below,
                // which will be the activation of the pushed statement
                // context.
                statementContext.setActivation(parentAct);

                org.apache.derby.iapi.sql.PreparedStatement ps =
                        lcc.prepareInternalStatement(insertSQL.toString());
                Activation act = ps.getActivation(lcc, false);

                statementContext.setActivation(act);

                // in this for loop we are assigning values for parameters
                //in sql constructed earlier VALUES (?, ..)
                for (int i=1, paramPosition=0; i<=rd.getColumnCount(); i++) {
                    // if the column got updated, do following
                    if (columnGotUpdated[i-1]) { 
                        act.getParameterValueSet().
                                getParameterForSet(paramPosition++).
                                setValue(updateRow.getColumn(i));
                    }
                }
                // Don't see any timeout when inserting rows (use 0)
                //execute the insert
                org.apache.derby.iapi.sql.ResultSet rs =
          ps.executeSubStatement(activation, act, true, 0L);
                act.close();

                lcc.popStatementContext(statementContext, null);
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
            } catch (Throwable t) {
                throw closeOnTransactionError(t);
View Full Code Here

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

            //using quotes around the cursor name to preserve case sensitivity
            updateWhereCurrentOfSQL.append(" WHERE CURRENT OF " +
                    IdUtil.normalToDelimited(getCursorName()));

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

            if (currSC != null) {
                parentAct = currSC.getActivation();
            }

            // Context used for preparing, don't set any timeout (use 0)
            statementContext = lcc.pushStatementContext(isAtomic, false, updateWhereCurrentOfSQL.toString(), null, false, 0L);

            // A priori, the new statement context inherits the activation of
            // the existing statementContext, so that that activation ends up
            // as parent of the new activation 'act' created below, which will
            // be the activation of the pushed statement context.
            statementContext.setActivation(parentAct);

            org.apache.derby.iapi.sql.PreparedStatement ps = lcc.prepareInternalStatement(updateWhereCurrentOfSQL.toString());
            Activation act = ps.getActivation(lcc, false);

            statementContext.setActivation(act);

            //in this for loop we are assigning values for parameters in sql constructed earlier with columnname=?,...
            for (int i=1, paramPosition=0; i<=rd.getColumnCount(); i++) {
                if (columnGotUpdated[i-1])  //if the column got updated, do following
                    act.getParameterValueSet().getParameterForSet(paramPosition++).setValue(updateRow.getColumn(i));
            }
            // Don't set any timeout when updating rows (use 0)
            // Execute the update where current of sql.
            org.apache.derby.iapi.sql.ResultSet rs =
        ps.executeSubStatement(activation, act, true, 0L);
            SQLWarning w = act.getWarnings();
            if (w != null) {
                addWarning(w);
            }
            act.close();
            //For forward only resultsets, after a update, the ResultSet will be positioned right before the next row.
            if (getType() == TYPE_FORWARD_ONLY) {
                currentRow = null;
            } else {
                movePosition(RELATIVE, 0, "relative");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.