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

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


    )
    throws StandardException
  {
    Parser            p;
    ValueNode          clauseTree;
    LanguageConnectionContext  lcc = getLanguageConnectionContext();
    CompilerContext       compilerContext = getCompilerContext();

    /* Get a Statement to pass to the parser */

    /* We're all set up to parse. We have to build a compilable SQL statement
     * before we can parse -  So, we goober up a VALUES defaultText.
     */
    String select = "SELECT " + clauseText + " FROM " + td.getQualifiedName();
   
    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();
       
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
    StatementNode qt = p.parseStatement(select);
    if (SanityManager.DEBUG)
    {
      if (! (qt instanceof CursorNode))
      {
        SanityManager.THROWASSERT(
          "qt expected to be instanceof CursorNode, not " +
          qt.getClass().getName());
      }
      CursorNode cn = (CursorNode) qt;
      if (! (cn.getResultSetNode() instanceof SelectNode))
      {
        SanityManager.THROWASSERT(
          "cn.getResultSetNode() expected to be instanceof SelectNode, not " +
          cn.getResultSetNode().getClass().getName());
      }
    }

    clauseTree = ((ResultColumn)
              ((CursorNode) qt).getResultSetNode().getResultColumns().elementAt(0)).
                  getExpression();

    lcc.popCompilerContext(newCC);

    return  clauseTree;
  }
View Full Code Here


    )
    throws StandardException
  {
    Parser            p;
    ValueNode          checkTree;
    LanguageConnectionContext  lcc = getLanguageConnectionContext();
    CompilerContext       compilerContext = getCompilerContext();

    /* Get a Statement to pass to the parser */

    /* We're all set up to parse. We have to build a compile SQL statement
     * before we can parse - we just have a WHERE clause right now.
     * So, we goober up a SELECT * FROM table WHERE checkDefs.
     */
    String select = "SELECT * FROM " +
                  td.getQualifiedName() +
                  " WHERE " +
                  checkConstraintText;
   
    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();
       
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
    StatementNode qt = p.parseStatement(select);
    if (SanityManager.DEBUG)
    {
      if (! (qt instanceof CursorNode))
      {
        SanityManager.THROWASSERT(
          "qt expected to be instanceof CursorNode, not " +
          qt.getClass().getName());
      }
      CursorNode cn = (CursorNode) qt;
      if (! (cn.getResultSetNode() instanceof SelectNode))
      {
        SanityManager.THROWASSERT(
          "cn.getResultSetNode() expected to be instanceof SelectNode, not " +
          cn.getResultSetNode().getClass().getName());
      }
    }

    checkTree = ((SelectNode) ((CursorNode) qt).getResultSetNode()).getWhereClause();

    lcc.popCompilerContext(newCC);

    return  checkTree;
  }
View Full Code Here

      /*
      ** Find the language connection context.  Get
      ** it each time in case a connection is dropped.
      */
      LanguageConnectionContext lcc = (LanguageConnectionContext)
          cm.getContext(LanguageConnectionContext.CONTEXT_ID);
     


      if (!((org.apache.derby.impl.sql.catalog.DataDictionaryImpl) (lcc.getDataDictionary())).readOnlyUpgrade) {

        //bug 4821 - First try compiling on a nested transaction so we can release
        //the locks after the compilation. But if we get lock time out on the
        //nested transaction, then go ahead and do the compilation on the user
        //transaction. When doing the compilation on user transaction, the locks
        //acquired for recompilation will be released at the end of the user transaction.
        TransactionController nestedTC;
        try
        {
          nestedTC = lcc.getTransactionCompile().startNestedUserTransaction(false);
        }
        catch (StandardException se)
        {
          // If I cannot start a Nested User Transaction use the parent
          // transaction to do all the work.
View Full Code Here

  {
    /*
    ** Get a new compiler context, so the parsing of the text
    ** doesn't mess up anything in the current context
    */
    LanguageConnectionContext lcc = getLanguageConnectionContext();
    CompilerContext newCC = lcc.pushCompilerContext();
    if (internalSQL)
        newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);

    try
    {
      Parser p = newCC.getParser();
      return p.parseStatement(sql);
    }

    finally
    {
      lcc.popCompilerContext(newCC);
    }
  }
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.getAuthorizationId();
    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

    public String toString()
    {
        if ( connString == null )
        {
           
            LanguageConnectionContext lcc = getLanguageConnection();

            connString =
              this.getClass().getName() + "@" + this.hashCode() + " " +
                lcc.xidStr +                 
                    lcc.getTransactionExecute().getTransactionIdString() +
                    "), " +
                lcc.lccStr +
                    Integer.toString(lcc.getInstanceNumber()) + "), " +
                lcc.dbnameStr + lcc.getDbname() + "), " +
                lcc.drdaStr + lcc.getDrdaID() + ") ";
        }      
       
        return connString;
    }
View Full Code Here

       been initialized and therefore can give a NullPointerException
     */
    DataDictionary dd = super.getDataDictionary();
     if (dd == null)
     {
        LanguageConnectionContext lcc = (LanguageConnectionContext)
        ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);
        dd = lcc.getDataDictionary();
      setDataDictionary(dd);
      }
    return dd;
   }
View Full Code Here

        {
            clean( false );
        } catch (StandardException se)
        {
            //Doing check for lcc and db to be certain
            LanguageConnectionContext lcc = getLCC();
            if (lcc != null)
            {
                Database db = lcc.getDatabase();
                boolean isactive = (db != null ? db.isActive() : false);
                lcc.getContextManager().cleanupOnError(se, isactive);
            }
        }
    }
View Full Code Here

    cm.setLocaleFinder(this);
    pushDbContext(cm);

    // push a database shutdown context
    // we also need to push a language connection context.
    LanguageConnectionContext lctx = lcf.newLanguageConnectionContext(cm, tc, lf, this, user, drdaID, dbname);

    // push the context that defines our class factory
    pushClassFactoryContext(cm, lcf.getClassFactory());

    // we also need to push an execution context.
    ExecutionFactory ef = lcf.getExecutionFactory();

    ef.newExecutionContext(cm);
    //
    //Initialize our language connection context. Note: This is
    //a bit of a hack. Unfortunately, we can't initialize this
    //when we push it. We first must push a few more contexts.
    lctx.initialize();   

    // Need to commit this to release locks gotten in initialize. 
    // Commit it but make sure transaction not have any updates.
    lctx.internalCommitNoSync(
      TransactionController.RELEASE_LOCKS |
      TransactionController.READONLY_TRANSACTION_INITIALIZATION);

    return lctx;
View Full Code Here

    /** Returns the default value for the transaction timeout in milliseconds
     *  setted up by the system properties.
     */
    private long getDefaultXATransactionTimeout() throws XAException {
        try {
            LanguageConnectionContext lcc = con.getLanguageConnection();
            TransactionController tc = lcc.getTransactionExecute();

            long timeoutMillis = 1000 * (long) PropertyUtil.getServiceInt(
                tc,
                Property.PROP_XA_TRANSACTION_TIMEOUT,
                0,
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.