Package org.apache.derby.iapi.sql.conn

Examples of org.apache.derby.iapi.sql.conn.LanguageConnectionContext


    throws SQLException {
    if ( getEmbedConnection().isClosed())
      throw Util.noCurrentConnection();

    boolean notInSoftUpgradeMode;
        LanguageConnectionContext lcc = getLanguageConnectionContext();
    try {
      notInSoftUpgradeMode =
               lcc.getDataDictionary().checkVersion(
            DataDictionary.DD_VERSION_CURRENT,null);
            InterruptStatus.restoreIntrFlagIfSeen();
    } catch (Throwable t) {
      throw handleException(t);
    }
View Full Code Here


                     String  spsText,
                     boolean net)
    throws StandardException, SQLException
  {

    LanguageConnectionContext lcc = getLanguageConnectionContext();

    /* We now need to do this in sub transaction because we could possibly recompile SPS
     * later, and the recompile is in a sub transaction, and will update the SYSSTATEMENTS
     * entry.  Don't want to block.
     */
    lcc.beginNestedTransaction(true);

    DataDictionary dd = getLanguageConnectionContext().getDataDictionary();
    SPSDescriptor spsd = dd.getSPSDescriptor(
                    spsName,
                    net ? dd.getSysIBMSchemaDescriptor() :
                    dd.getSystemSchemaDescriptor());
    lcc.commitNestedTransaction();

    if (spsd == null)
    {
      throw Util.notImplemented(spsName);
    }
View Full Code Here

  private void checkUserIsNotARole() throws SQLException {
    TransactionResourceImpl tr = getTR();

    try {
      tr.startTransaction();
            LanguageConnectionContext lcc = tr.getLcc();
            String username = lcc.getSessionUserId();

      DataDictionary dd = lcc.getDataDictionary();

      // Check is only performed if we have
      // derby.database.sqlAuthorization == true and we have
      // upgraded dictionary to at least level 10.4 (roles
      // introduced in 10.4):
      if (lcc.usesSqlAuthorization() &&
        dd.checkVersion(DataDictionary.DD_VERSION_DERBY_10_4, null)) {

        TransactionController tc = lcc.getTransactionExecute();

        String failedString =
          MessageService.getTextMessage(MessageId.AUTH_INVALID);

        if (dd.getRoleDefinitionDescriptor(username) != null) {
View Full Code Here

   * @throws SQLException if actual authenticationId is different
   * from authenticationId of database owner.
   */
  private void checkIsDBOwner(int operation) throws SQLException
  {
    final LanguageConnectionContext lcc = getLanguageConnection();
        final String actualId = lcc.getSessionUserId();
    final String dbOwnerId = lcc.getDataDictionary().
      getAuthorizationDatabaseOwner();
    if (!actualId.equals(dbOwnerId)) {
      switch (operation) {
      case OP_ENCRYPT:
        throw newSQLException(SQLState.AUTH_ENCRYPT_NOT_DB_OWNER,
View Full Code Here

  {
    synchronized(getConnectionSynchronization())
    {
                        setupContextStack();
      try {
                LanguageConnectionContext lcc = getLanguageConnection();
                lcc.setReadOnly(readOnly);
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
      } catch (StandardException e) {
        throw handleException(e);
      } finally {
        restoreContextStack();
View Full Code Here

    synchronized(getConnectionSynchronization())
    {
            setupContextStack();
      try {
                LanguageConnectionContext lcc = getLanguageConnection();
                lcc.setIsolationLevel(iLevel);
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
      } catch (StandardException e) {
        throw handleException(e);
      } finally {
        restoreContextStack();
View Full Code Here

  public void resetFromPool() throws SQLException {
    synchronized (getConnectionSynchronization())
    {
      setupContextStack();
      try {
                LanguageConnectionContext lcc = getLanguageConnection();
                lcc.resetFromPool();
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
      } catch (StandardException t) {
        throw handleException(t);
      }
      finally
View Full Code Here

    synchronized (getConnectionSynchronization())
    {
            setupContextStack();
      try
      {
                LanguageConnectionContext lcc = getLanguageConnection();
        XATransactionController tc =
                    (XATransactionController)lcc.getTransactionExecute();

        int ret = tc.xa_prepare();

        if (ret == XATransactionController.XA_RDONLY)
        {
          // On a prepare call, xa allows an optimization that if the
          // transaction is read only, the RM can just go ahead and
          // commit it.  So if store returns this read only status -
          // meaning store has taken the liberty to commit already - we
          // needs to turn around and call internalCommit (without
          // committing the store again) to make sure the state is
          // consistent.  Since the transaction is read only, there is
          // probably not much that needs to be done.

                    lcc.internalCommit(false /* don't commitStore again */);
        }
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
        return ret;
      } catch (StandardException t)
      {
View Full Code Here

       * they're not needed and they wouldn't work in a read only database.
       * We can't set savepoints for commit/rollback because they'll get
       * blown away before we try to clear them.
       */

      LanguageConnectionContext lccToUse = activation.getLanguageConnectionContext();

       if (lccToUse.getLogStatementText())
      {
        HeaderPrintWriter istream = Monitor.getStream();
        String xactId = lccToUse.getTransactionExecute().getActiveStateTxIdString();
        String pvsString = "";
        ParameterValueSet pvs = activation.getParameterValueSet();
        if (pvs != null && pvs.getParameterCount() > 0)
        {
          pvsString = " with " + pvs.getParameterCount() +
              " parameters " + pvs.toString();
        }
        istream.printlnWithHeader(LanguageConnectionContext.xidStr +
                      xactId +
                      "), " +
                      LanguageConnectionContext.lccStr +
                      lccToUse.getInstanceNumber() +
                      "), " +
                      LanguageConnectionContext.dbnameStr +
                      lccToUse.getDbname() +
                      "), " +
                      LanguageConnectionContext.drdaStr +
                      lccToUse.getDrdaID() +
                      "), Executing prepared statement: " +
                      getSource() +
                      " :End prepared statement" +
                      pvsString);
      }

      ParameterValueSet pvs = activation.getParameterValueSet();

      /* put it in try block to unlock the PS in any case
       */
      if (!spsAction) {
      // only re-prepare if this isn't an SPS for a trigger-action;
      // if it _is_ an SPS for a trigger action, then we can't just
      // do a regular prepare because the statement might contain
      // internal SQL that isn't allowed in other statements (such as a
      // static method call to get the trigger context for retrieval
      // of "new row" or "old row" values).  So in that case we
      // skip the call to 'rePrepare' and if the statement is out
      // of date, we'll get a NEEDS_COMPILE exception when we try
      // to execute.  That exception will be caught by the executeSPS()
      // method of the GenericTriggerExecutor class, and at that time
      // the SPS action will be recompiled correctly.
        rePrepare(lccToUse);
      }

      StatementContext statementContext = lccToUse.pushStatementContext(
        isAtomic, updateMode==CursorNode.READ_ONLY, getSource(), pvs, rollbackParentContext, timeoutMillis);

      if (needsSavepoint())
      {
        /* Mark this position in the log so that a statement
        * rollback will undo any changes.
        */
        statementContext.setSavePoint();
        needToClearSavePoint = true;
      }

      if (executionConstants != null)
      {
        lccToUse.validateStmtExecution(executionConstants);
      }

      ResultSet resultSet = null;
      try {
 
        resultSet = activation.execute();

        resultSet.open();
      } catch (StandardException se) {
        /* Cann't handle recompiling SPS action recompile here */
        if (!se.getMessageId().equals(SQLState.LANG_STATEMENT_NEEDS_RECOMPILE)
             || spsAction)
          throw se;
        statementContext.cleanupOnError(se);
        continue recompileOutOfDatePlan;

      }


      if (needToClearSavePoint)
      {
        /* We're done with our updates */
        statementContext.clearSavePoint();
      }

      lccToUse.popStatementContext(statementContext, null);         

      if (activation.isSingleExecution() && resultSet.isClosed())
      {
        // if the result set is 'done', i.e. not openable,
        // then we can also release the activation.
View Full Code Here

    synchronized (getConnectionSynchronization())
    {
            setupContextStack();
      try
      {
                LanguageConnectionContext lcc = getLanguageConnection();
                lcc.xaCommit(onePhase);
                InterruptStatus.restoreIntrFlagIfSeen(lcc);
      } catch (StandardException t)
      {
        throw handleException(t);
      }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.conn.LanguageConnectionContext

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.