コード例 #1
0
ファイル: DrvObj.java プロジェクト: JordanChin/Ingres
  protected void readInfo() throws SQLException {
    while (msg.moreData()) {
      short param_id = msg.readShort();
      short param_len = msg.readShort();

      switch (param_id) {
        case MSG_IP_TRACE:
          {
            if (trace.enabled() || conn.dbms_log.enabled()) {
              String txt = msg.readString(param_len);
              trace.log("DBMS TRACE: " + txt);
              conn.dbms_log.write(txt);
            } else msg.skip(param_len);
            break;
          }

        default:
          if (trace.enabled(1)) trace.write(tr_id + ": Invalid info param ID " + param_id);
          throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
      }
    }

    return;
  } // readInfo
コード例 #2
0
ファイル: DrvObj.java プロジェクト: JordanChin/Ingres
  protected boolean readResult() throws SQLException {
    while (msg.moreData()) {
      short param_id = msg.readShort();
      short param_len = msg.readShort();

      switch (param_id) {
        case MSG_RP_ROWCOUNT:
          switch (param_len) {
            case 1:
              rslt_val_rowcnt = msg.readByte();
              break;
            case 2:
              rslt_val_rowcnt = msg.readShort();
              break;
            case 4:
              rslt_val_rowcnt = msg.readInt();
              break;

            default:
              if (trace.enabled(1)) trace.write(tr_id + ": Invalid row count length: " + param_len);
              throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_items |= RSLT_ROW_CNT;
          break;

        case MSG_RP_XACT_END:
          if (param_len > 0) {
            if (trace.enabled(1)) trace.write(tr_id + ": Invalid XACT param length: " + param_len);
            throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_flags |= MSG_RF_XACT_END;
          conn.endXact();
          break;

        case MSG_RP_STMT_ID:
          if (param_len != 8) {
            if (trace.enabled(1)) trace.write(tr_id + ": Invalid stmt ID length: " + param_len);
            throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_val_stmt = (((long) msg.readInt()) << 32) | (((long) msg.readInt()) & 0xffffffff);
          rslt_items |= RSLT_STMT_ID;
          break;

        case MSG_RP_FETCH_LIMIT:
          switch (param_len) {
            case 1:
              rslt_val_fetch = msg.readByte();
              break;
            case 2:
              rslt_val_fetch = msg.readShort();
              break;
            case 4:
              rslt_val_fetch = msg.readInt();
              break;

            default:
              if (trace.enabled(1))
                trace.write(tr_id + ": Invalid fetch limit length: " + param_len);
              throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_items |= RSLT_PREFETCH;
          break;

        case MSG_RP_EOD:
          if (param_len != 0) {
            trace.write(tr_id + ": Invalid EOD length: " + param_len);
            throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_flags |= MSG_RF_EOD;
          break;

        case MSG_RP_PROC_RESULT:
          switch (param_len) {
            case 1:
              setProcResult((int) msg.readByte());
              break;
            case 2:
              setProcResult((int) msg.readShort());
              break;
            case 4:
              setProcResult(msg.readInt());
              break;

            default:
              if (trace.enabled(1))
                trace.write(tr_id + ": Invalid proc result length: " + param_len);
              throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }
          break;

        case MSG_RP_READ_ONLY:
          if (param_len != 0) {
            trace.write(tr_id + ": Invalid READ_ONLY length: " + param_len);
            throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_flags |= MSG_RF_READ_ONLY;
          break;

        case MSG_RP_TBLKEY:
          if (param_len != MSG_RPV_TBLKEY_LEN) {
            if (trace.enabled(1)) trace.write(tr_id + ": Invalid table key length: " + param_len);
            throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          if (rslt_val_tblkey == null) rslt_val_tblkey = new byte[param_len];
          msg.readBytes(rslt_val_tblkey, 0, param_len);
          rslt_items |= RSLT_TBLKEY;
          break;

        case MSG_RP_OBJKEY:
          if (param_len != MSG_RPV_OBJKEY_LEN) {
            if (trace.enabled(1)) trace.write(tr_id + ": Invalid object key length: " + param_len);
            throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          if (rslt_val_objkey == null) rslt_val_objkey = new byte[param_len];
          msg.readBytes(rslt_val_objkey, 0, param_len);
          rslt_items |= RSLT_OBJKEY;
          break;

        case MSG_RP_FLAGS:
          {
            int flags;

            switch (param_len) {
              case 1:
                flags = (int) msg.readByte();
                break;
              case 2:
                flags = (int) msg.readShort();
                break;
              case 4:
                flags = msg.readInt();
                break;

              default:
                if (trace.enabled(1))
                  trace.write(tr_id + ": Invalid result flags length: " + param_len);
                throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
            }

            rslt_flags |= flags;
            if ((flags & MSG_RF_XACT_END) != 0) conn.endXact();
            break;
          }

        case MSG_RP_ROW_STATUS:
          switch (param_len) {
            case 1:
              rslt_val_rowstat = msg.readByte();
              break;
            case 2:
              rslt_val_rowstat = msg.readShort();
              break;
            case 4:
              rslt_val_rowstat = msg.readInt();
              break;

            default:
              if (trace.enabled(1))
                trace.write(tr_id + ": Invalid row status length: " + param_len);
              throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_items |= RSLT_ROW_STAT;
          break;

        case MSG_RP_ROW_POS:
          switch (param_len) {
            case 1:
              rslt_val_rowpos = msg.readByte();
              break;
            case 2:
              rslt_val_rowpos = msg.readShort();
              break;
            case 4:
              rslt_val_rowpos = msg.readInt();
              break;

            default:
              if (trace.enabled(1))
                trace.write(tr_id + ": Invalid row position length: " + param_len);
              throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
          }

          rslt_items |= RSLT_ROW_POS;
          break;

        default:
          if (trace.enabled(1)) trace.write(tr_id + ": Invalid result param ID " + param_id);
          throw SqlExFactory.get(ERR_GC4002_PROTOCOL_ERR);
      }
    }

    return (false);
  } // readResult