Package org.apache.derby.iapi.sql

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


    checkStmt.append(")");
 
    ResultSet rs = null;
    try
    {
      PreparedStatement ps = lcc.prepareInternalStatement(td.getSchemaDescriptor(), checkStmt.toString());

      rs = ps.execute(lcc, false);
      ExecRow row = rs.getNextRow();
      if (SanityManager.DEBUG)
      {
        if (row == null)
        {
View Full Code Here


      CursorActivation cursorActivation = lcc.lookupCursorActivation(cursorName);

      if (cursorActivation != null)
      {
        // check we are compiled against the correct cursor
        PreparedStatement cps = cursorActivation.getPreparedStatement();

        if (psName.equals(cps.getObjectName())) {
          cursor = cursorActivation.getCursorResultSet();
          target = cursorActivation.getTargetResultSet();
          /* beetle 3865: updateable cursor using index. 2 way communication between
           * update activation and cursor activation. Cursor passes index scan to
           * update and update passes heap conglom controller to cursor.
View Full Code Here

      Activation activation,
      ResultSet rs,
      NoPutResultSet[] subqueryTrackingArray)
    throws StandardException
  {
    PreparedStatement preStmt = activation.getPreparedStatement();

    // If the prepared statement is null then the result set is being
    // finished as a result of a activation being closed during a recompile.
    // In this case statistics should not be generated.
    if (preStmt == null)
      return null;




    ResultSetStatistics topResultSetStatistics;

    if (rs instanceof NoPutResultSet)
    {
      topResultSetStatistics =
                  getResultSetStatistics((NoPutResultSet) rs);
    }
    else
    {
      topResultSetStatistics = getResultSetStatistics(rs);
    }

    /* Build up the info on the materialized subqueries */
    int subqueryTrackingArrayLength =
        (subqueryTrackingArray == null) ? 0 :
          subqueryTrackingArray.length;
    ResultSetStatistics[] subqueryRSS =
        new ResultSetStatistics[subqueryTrackingArrayLength];
    boolean anyAttached = false;
    for (int index = 0; index < subqueryTrackingArrayLength; index++)
    {
      if (subqueryTrackingArray[index] != null &&
        subqueryTrackingArray[index].getPointOfAttachment() == -1)
      {
        subqueryRSS[index] =
            getResultSetStatistics(subqueryTrackingArray[index]);
        anyAttached = true;
      }
    }
    if (anyAttached == false)
    {
      subqueryRSS = null;
    }

    // Get the info on all of the materialized subqueries (attachment point = -1)
    return new RunTimeStatisticsImpl(
                preStmt.getSPSName(),
                activation.getCursorName(),
                preStmt.getSource(),
                preStmt.getCompileTimeInMillis(),
                preStmt.getParseTimeInMillis(),
                preStmt.getBindTimeInMillis(),
                preStmt.getOptimizeTimeInMillis(),
                preStmt.getGenerateTimeInMillis(),
                rs.getExecuteTime(),
                preStmt.getBeginCompileTimestamp(),
                preStmt.getEndCompileTimestamp(),
                rs.getBeginExecutionTimestamp(),
                rs.getEndExecutionTimestamp(),
                subqueryRSS,
                topResultSetStatistics);
  }
View Full Code Here

    @exception StandardException thrown if unable to make it valid
   */
  public void makeValid(LanguageConnectionContext lcc)
    throws StandardException
  {
    PreparedStatement ps;

    // REMIND: will want to go through dependency list
    // and check if we can make it valid just on faith,
    // i.e. when it was marked 'possibly invalid' due
    // to a rollback or some similar action.
View Full Code Here

    SQLText = sql;   

    try {
      Activation activation;
      try {
        PreparedStatement preparedStatement = lcc.prepareInternalStatement(sql);
        activation =
          preparedStatement.getActivation(lcc, resultSetType == JDBC20Translation.TYPE_SCROLL_INSENSITIVE);
        checkRequiresCallableStatement(activation);
       } catch (Throwable t) {
        throw handleException(t);
       }
View Full Code Here

          }
        }

        // if this was a prepared statement, this just
        // gets it for us, it won't recompile unless it is invalid.
        PreparedStatement ps = a.getPreparedStatement();
        ps.rePrepare(lcc);
        getWarnings(ps.getCompileTimeWarnings());


        /*
        ** WARNING WARNING
        **
        ** Any state set in the activation before execution *must* be copied
        ** to the new activation in GenericActivationHolder.execute() when
        ** the statement has been recompiled. State such as
        ** singleExecution, cursorName, holdability, maxRows.
        */

        if (cursorName != null)
        {
          a.setCursorName(cursorName);
        }
        a.setResultSetHoldability(resultSetHoldability != JDBC30Translation.CLOSE_CURSORS_AT_COMMIT);

        //reset the activation to clear warnings
        //and clear existing result sets in case this has been cached
        a.reset();
        a.setMaxRows(maxRows);
        ResultSet resultsToWrap = ps.execute(a, executeQuery, executeUpdate, false);
        getWarnings(a.getWarnings());


        if (resultsToWrap.returnsRows()) {
          EmbedResultSet lresults = factory.newEmbedResultSet(getEmbedConnection(), resultsToWrap, forMetaData, this, ps.isAtomic());
          results = lresults;


          // Set up the finalization of the ResultSet to
          // mark the activation as unused. It will be
          // closed sometime later by the connection
          // outside of finalization.
          if (a.isSingleExecution())
            lresults.finalizeActivation = a;

          updateCount = -1;
          retval = true;
        }
        else {

          // Only applipable for an insert statement, which does not return rows.
          //the auto-generated keys resultset will be null if used for non-insert statement
          if (a.getAutoGeneratedKeysResultsetMode() && (resultsToWrap.getAutoGeneratedKeysResultset() != null))
          {
            resultsToWrap.getAutoGeneratedKeysResultset().open();
            autoGeneratedKeysResultSet = factory.newEmbedResultSet(getEmbedConnection(),
              resultsToWrap.getAutoGeneratedKeysResultset(), false, this, ps.isAtomic());
          }

          updateCount = resultsToWrap.modifiedRowCount();

          resultsToWrap.finish()// Don't need the result set any more
View Full Code Here

    checkStmt.append(")");
 
    ResultSet rs = null;
    try
    {
      PreparedStatement ps = lcc.prepareInternalStatement(td.getSchemaDescriptor(), checkStmt.toString());

      rs = ps.execute(lcc, false);
      ExecRow row = rs.getNextRow();
      if (SanityManager.DEBUG)
      {
        if (row == null)
        {
View Full Code Here

    AlterTableConstantAction.executeUpdate(lcc, updateStmt);
  }

  private static void executeUpdate(LanguageConnectionContext lcc, String updateStmt) throws StandardException
  {
    PreparedStatement ps = lcc.prepareInternalStatement(updateStmt);
    ResultSet rs = ps.execute(lcc, true);
    rs.close();
    rs.finish();
  }
View Full Code Here

    String maxStmt = "SELECT " + maxStr + "(\"" + columnName + "\")"  +
        "FROM \"" + td.getSchemaName() + "\".\"" + td.getName() + "\"";


    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    PreparedStatement ps = lcc.prepareInternalStatement(maxStmt);

    ResultSet rs = ps.execute(lcc, false);
    DataValueDescriptor[] rowArray = rs.getNextRow().getRowArray();
    rs.close();
    rs.finish();

    return rowArray[0].getLong();
View Full Code Here

    AlterTableConstantAction.executeUpdate(lcc, updateStmt);
  }

  private static void executeUpdate(LanguageConnectionContext lcc, String updateStmt) throws StandardException
  {
    PreparedStatement ps = lcc.prepareInternalStatement(updateStmt);

        // This is a substatement; for now, we do not set any timeout
        // for it. We might change this behaviour later, by linking
        // timeout to its parent statement's timeout settings.
    ResultSet rs = ps.executeSubStatement(lcc, true, 0L);
    rs.close();
  }
View Full Code Here

TOP

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

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.