public void addBatch() throws SQLException {

    checkStatus();
    ParameterValueSet pvs = getParms();

    int numberOfParameters = pvs.getParameterCount();

    for (int j = 1; j <= numberOfParameters; j++) {

      switch (pvs.getParameterMode(j)) {
        case JDBC30Translation.PARAMETER_MODE_IN:
        case JDBC30Translation.PARAMETER_MODE_UNKNOWN:
          break;
        case JDBC30Translation.PARAMETER_MODE_OUT:
        case JDBC30Translation.PARAMETER_MODE_IN_OUT:
          throw newSQLException(SQLState.OUTPUT_PARAMS_NOT_ALLOWED);
      }
    }

    super.addBatch();
  }
  /** @exception SQLException thrown on failure */
  public EmbedCallableStatement(
      EmbedConnection conn,
      String sql,
      int resultSetType,
      int resultSetConcurrency,
      int resultSetHoldability)
      throws SQLException {
    super(
        conn,
        sql,
        false,
        resultSetType,
        resultSetConcurrency,
        resultSetHoldability,
        Statement.NO_GENERATED_KEYS,
        null,
        null);

    // mark our parameters as for a callable statement
    ParameterValueSet pvs = getParms();

    // do we have a return parameter?
    hasReturnOutputParameter = pvs.hasReturnOutputParameter();
  }
  protected final boolean executeStatement(
      Activation a, boolean executeQuery, boolean executeUpdate) throws SQLException {
    // need this additional check (it's also in the super.executeStatement
    // to ensure we have an activation for the getParams
    checkExecStatus();
    synchronized (getConnectionSynchronization()) {
      wasNull = false;
      // Don't fetch the getParms into a local varibale
      // at this point because it is possible that the activation
      // associated with this callable statement may have become
      // stale. If the current activation is invalid, a new activation
      // will be created for it in executeStatement call below.
      // We should be using the ParameterValueSet associated with
      // the activation associated to the CallableStatement after
      // the executeStatement below. That ParameterValueSet is the
      // right object to hold the return value from the CallableStatement.
      try {
        getParms().validate();
      } catch (StandardException e) {
        throw EmbedResultSet.noStateChangeException(e);
      }

      /* KLUDGE - ? = CALL ... returns a ResultSet().  We
       * need executeUpdate to be false in that case.
       */
      boolean execResult =
          super.executeStatement(a, executeQuery, (executeUpdate && (!hasReturnOutputParameter)));

      // Fetch the getParms into a local variable now because the
      // activation associated with a CallableStatement at this
      // point(after the executStatement) is the current activation.
      // We can now safely stuff the return value of the
      // CallableStatement into the following ParameterValueSet object.
      ParameterValueSet pvs = getParms();

      /*
       ** If we have a return parameter, then we
       ** consume it from the returned ResultSet
       ** reset the ResultSet set to null.
       */
      if (hasReturnOutputParameter) {
        if (SanityManager.DEBUG) {
          SanityManager.ASSERT(
              results != null,
              "null results even though we are supposed to have a return parameter");
        }
        boolean gotRow = results.next();
        if (SanityManager.DEBUG) {
          SanityManager.ASSERT(gotRow, "the return resultSet didn't have any rows");
        }

        try {
          DataValueDescriptor returnValue = pvs.getReturnValueForSet();
          returnValue.setValueFromResultSet(results, 1, true);
        } catch (StandardException e) {
          throw EmbedResultSet.noStateChangeException(e);
        } finally {
          results.close();
          results = null;
        }

        // This is a form of ? = CALL which current is not a procedure call.
        // Thus there cannot be any user result sets, so return false. execResult
        // is set to true since a result set was returned, for the return parameter.
        execResult = false;
      }
      return execResult;
    }
  }