Пример #1
0
  /**
   * Set the commit mode on the system.
   *
   * @param commitMode The commit mode.
   * @exception SQLException If an error occurs.
   */
  private void setCommitMode(int commitMode) throws SQLException {
    // If auto-commit is on, then override the commit mode
    // to "NONE".
    if (autoCommit_) // @C5D && (!newAutoCommitSupport_))                                  // @C5C
    commitMode = COMMIT_MODE_NONE_;

    // Act only if the server commit mode is something other
    // then the what was requested.
    if (commitMode != serverCommitMode_) {

      JDSQLStatement sqlStatement =
          new JDSQLStatement("SET TRANSACTION ISOLATION LEVEL " + COMMIT_MODE_[commitMode]);

      // Send the execute immediate data stream.
      try {
        DBSQLRequestDS request = null; // @P0A
        DBReplyRequestedDS reply = null; // @P0A
        try {
          request =
              DBDSPool.getDBSQLRequestDS( // @P0C
                  DBSQLRequestDS.FUNCTIONID_EXECUTE_IMMEDIATE,
                  id_,
                  DBBaseRequestDS.ORS_BITMAP_RETURN_DATA + DBBaseRequestDS.ORS_BITMAP_SQLCA,
                  0);

          boolean extended = false; // @540
          if (connection_.getVRM() >= JDUtilities.vrm540) extended = true; // @540
          // Bidi-HCG request.setStatementText (sqlStatement.toString (),
          // connection_.unicodeConverter_, extended); // @C3C @P0C @540C
          request.setStatementText(
              sqlStatement.toString(), connection_.packageCCSID_Converter, extended); // Bidi-HCG
          request.setStatementType(sqlStatement.getNativeType());

          // This statement certainly does not need a cursor, but some
          // versions of the system choke when none is specified.
          request.setCursorName("MURCH", connection_.converter_); // @P0C

          reply = connection_.sendAndReceive(request); // @P0C

          int errorClass = reply.getErrorClass();
          int returnCode = reply.getReturnCode();

          if (errorClass != 0) JDError.throwSQLException(connection_, id_, errorClass, returnCode);
        } finally {
          if (request != null) {
            request.returnToPool();
            request = null;
          }
          if (reply != null) {
            reply.returnToPool();
            reply = null;
          } // Only errorClass Used from reply
        }
      } catch (DBDataStreamException e) {
        JDError.throwSQLException(JDError.EXC_INTERNAL, e);
      }

      serverCommitMode_ = commitMode;
    }
  }
Пример #2
0
  /**
   * Commit the current transaction.
   *
   * @exception SQLException If an error occurs.
   */
  void commit() throws SQLException {
    try {
      DBSQLRequestDS request = null; // @P0A
      DBReplyRequestedDS reply = null; // @P0A
      try {
        request =
            DBDSPool.getDBSQLRequestDS( // @P0C
                DBSQLRequestDS.FUNCTIONID_COMMIT, id_, DBBaseRequestDS.ORS_BITMAP_RETURN_DATA, 0);

        // Set cursor hold.
        // request.setHoldIndicator (1);                     // @C1
        request.setHoldIndicator(getHoldIndicator()); // @C1

        reply = connection_.sendAndReceive(request); // @P0C

        int errorClass = reply.getErrorClass();

        if (errorClass != 0) {
          int returnCode = reply.getReturnCode();
          JDError.throwSQLException(connection_, id_, errorClass, returnCode);
        }
      } finally {
        if (request != null) {
          request.returnToPool();
          request = null;
        }
        if (reply != null) {
          reply.returnToPool();
          reply = null;
        } // Only errorClass used from reply
      }

    } catch (DBDataStreamException e) {
      JDError.throwSQLException(JDError.EXC_INTERNAL, e);
    }

    resetServer();
    activeLocal_ = false; // @C4C
  }