Package org.apache.derby.iapi.sql

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


    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


    String maxStr = (increment > 0) ? "MAX" : "MIN";
        String maxStmt = "SELECT  " + maxStr + "(" +
                IdUtil.normalToDelimited(columnName) + ") FROM " +
                IdUtil.mkQualifiedName(td.getSchemaName(), td.getName());

    PreparedStatement ps = lcc.prepareInternalStatement(maxStmt);

        // This is a substatement, for now we do not set any timeout for it
        // We might change this later by linking timeout to parent statement
    ResultSet rs = ps.executeSubStatement(lcc, false, 0L);
    DataValueDescriptor[] rowArray = rs.getNextRow().getRowArray();
    rs.close();
    rs.finish();

    return rowArray[0].getLong();
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(checkStmt.toString());

            // 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.
      rs = ps.execute(lcc, false, 0L);
      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

    ** it.
    */
    LanguageConnectionContext lcc = (LanguageConnectionContext)
      ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);

    PreparedStatement ps = lcc.prepareInternalStatement(usingText);

    ResultSet rs = ps.execute(lcc, false);
    ExecRow row = null;
    row = rs.getNextRow();
    if (row == null)
    {
      throw StandardException.newException(SQLState.LANG_NO_ROWS_FROM_USING_DURING_EXECUTION);
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

    ** a statement from the text and execute
    ** it.
    */
    LanguageConnectionContext lcc = getLanguageConnectionContext();

    PreparedStatement ps = lcc.prepareInternalStatement(usingText);
 
    ResultSet rs = ps.execute(lcc, false);
   
    try {
      ExecRow row = rs.getNextRow();
      if (row == null)
      {
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.