Esempio n. 1
0
  public DB2RoutineParm(DBRProgressMonitor monitor, DB2Routine procedure, ResultSet dbResult)
      throws DBException {
    super();

    this.procedure = procedure;

    DB2DataSource db2DataSource = getDataSource();

    this.name = JDBCUtils.safeGetStringTrimmed(dbResult, "PARMNAME");
    this.scale = JDBCUtils.safeGetInteger(dbResult, "SCALE");
    this.length = JDBCUtils.safeGetInteger(dbResult, "LENGTH");
    this.remarks = JDBCUtils.safeGetStringTrimmed(dbResult, "REMARKS");
    this.rowType =
        CommonUtils.valueOf(DB2RoutineRowType.class, JDBCUtils.safeGetString(dbResult, "ROWTYPE"));

    String typeSchemaName = JDBCUtils.safeGetStringTrimmed(dbResult, "TYPESCHEMA");
    String typeModuleName = JDBCUtils.safeGetStringTrimmed(dbResult, "TYPEMODULENAME");
    this.typeName = JDBCUtils.safeGetStringTrimmed(dbResult, "TYPENAME");
    this.dataTypeSchema = db2DataSource.getSchema(monitor, typeSchemaName);

    // -------------------
    // Search for DataType
    // -------------------

    // First Search in System/Standard Data Types
    this.dataType = db2DataSource.getLocalDataType(typeName);
    if (this.dataType != null) {
      return;
    }

    // Not found : Search for a UDT in Module
    if (typeModuleName != null) {
      DB2Module db2Module =
          DB2Utils.findModuleBySchemaNameAndName(
              monitor, db2DataSource, typeSchemaName, typeModuleName);
      this.dataType = db2Module.getType(monitor, typeName);
      return;
    }

    // Not found, search for a UDT
    this.dataType = this.dataTypeSchema.getUDT(monitor, typeName);
  }
Esempio n. 2
0
  // -----------------
  // Constructors
  // -----------------
  public DB2Index(
      DBRProgressMonitor monitor, DB2Schema schema, DB2TableBase table, ResultSet dbResult) {
    super(schema, table, JDBCUtils.safeGetStringTrimmed(dbResult, "INDNAME"), null, true);

    DB2DataSource db2DataSource = (DB2DataSource) schema.getDataSource();

    this.uniqueRule =
        CommonUtils.valueOf(DB2UniqueRule.class, JDBCUtils.safeGetString(dbResult, "UNIQUERULE"));
    this.colCount = JDBCUtils.safeGetInteger(dbResult, "COLCOUNT");
    this.uniqueColCount = JDBCUtils.safeGetInteger(dbResult, "UNIQUE_COLCOUNT");
    this.pctFree = JDBCUtils.safeGetInteger(dbResult, "PCTFREE");
    this.indexId = JDBCUtils.safeGetInteger(dbResult, "IID");
    this.minPctUsed = JDBCUtils.safeGetInteger(dbResult, "MINPCTUSED");
    this.reverseScans = JDBCUtils.safeGetBoolean(dbResult, "REVERSE_SCANS", DB2YesNo.Y.name());
    this.tablespaceId = JDBCUtils.safeGetInteger(dbResult, "TBSPACEID");
    this.pageSplit =
        CommonUtils.valueOf(
            DB2IndexPageSplit.class, JDBCUtils.safeGetStringTrimmed(dbResult, "PAGESPLIT"));
    this.remarks = JDBCUtils.safeGetString(dbResult, "REMARKS");

    this.createTime = JDBCUtils.safeGetTimestamp(dbResult, "CREATE_TIME");
    this.madeUnique = JDBCUtils.safeGetBoolean(dbResult, "MADE_UNIQUE");

    this.statsTime = JDBCUtils.safeGetTimestamp(dbResult, "STATS_TIME");
    this.fullKeycard = JDBCUtils.safeGetLong(dbResult, "FULLKEYCARD");
    this.firstKeycard = JDBCUtils.safeGetLong(dbResult, "FIRSTKEYCARD");
    this.first2Keycard = JDBCUtils.safeGetLong(dbResult, "FIRST2KEYCARD");
    this.first3Keycard = JDBCUtils.safeGetLong(dbResult, "FIRST3KEYCARD");
    this.first4Keycard = JDBCUtils.safeGetLong(dbResult, "FIRST4KEYCARD");
    this.clusterRatio = JDBCUtils.safeGetInteger(dbResult, "CLUSTERRATIO");

    if (db2DataSource.isAtLeastV9_5()) {
      this.compression = JDBCUtils.safeGetBoolean(dbResult, "COMPRESSION", DB2YesNo.Y.name());
    }

    // DF: Could have been done in constructor. More "readable" to do it here
    this.db2IndexType =
        CommonUtils.valueOf(
            DB2IndexType.class, JDBCUtils.safeGetStringTrimmed(dbResult, "INDEXTYPE"));
    this.indexType = db2IndexType.getDBSIndexType();
  }
Esempio n. 3
0
  // -----------------
  // Constructors
  // -----------------
  public DB2TableBase(DBRProgressMonitor monitor, DB2Schema schema, ResultSet dbResult) {
    super(schema, true);

    setName(JDBCUtils.safeGetString(dbResult, "TABNAME"));

    DB2DataSource db2DataSource = schema.getDataSource();

    this.owner = JDBCUtils.safeGetString(dbResult, "OWNER");
    this.tableId = JDBCUtils.safeGetInteger(dbResult, "TABLEID");
    this.createTime = JDBCUtils.safeGetTimestamp(dbResult, "CREATE_TIME");
    this.invalidateTime = JDBCUtils.safeGetTimestamp(dbResult, "INVALIDATE_TIME");
    this.lastRegenTime = JDBCUtils.safeGetTimestamp(dbResult, "LAST_REGEN_TIME");

    this.remarks = JDBCUtils.safeGetString(dbResult, "REMARKS");

    if (db2DataSource.isAtLeastV9_5()) {
      this.alterTime = JDBCUtils.safeGetTimestamp(dbResult, "ALTER_TIME");
      this.ownerType =
          CommonUtils.valueOf(DB2OwnerType.class, JDBCUtils.safeGetString(dbResult, "OWNERTYPE"));
    }
  }
Esempio n. 4
0
  // -----------------------
  // Constructors
  // -----------------------
  public DB2Sequence(DB2Schema schema, ResultSet dbResult) {
    super(schema, JDBCUtils.safeGetString(dbResult, "SEQNAME"), true);

    DB2DataSource db2DataSource = schema.getDataSource();

    this.owner = JDBCUtils.safeGetString(dbResult, "OWNER");
    this.seqId = JDBCUtils.safeGetInteger(dbResult, "SEQID");
    this.seqType =
        CommonUtils.valueOf(DB2SequenceType.class, JDBCUtils.safeGetString(dbResult, "SEQTYPE"));
    this.incrementBy = JDBCUtils.safeGetLong(dbResult, "INCREMENT");
    this.start = JDBCUtils.safeGetLong(dbResult, "START");
    this.maxValue = JDBCUtils.safeGetLong(dbResult, "MAXVALUE");
    this.minValue = JDBCUtils.safeGetLong(dbResult, "MINVALUE");
    this.nextCacheFirstValue = JDBCUtils.safeGetLong(dbResult, "NEXTCACHEFIRSTVALUE");
    this.cycle = JDBCUtils.safeGetBoolean(dbResult, "CYCLE", DB2YesNo.Y.name());
    this.cache = JDBCUtils.safeGetInteger(dbResult, "CACHE");
    this.order = JDBCUtils.safeGetBoolean(dbResult, "ORDER", DB2YesNo.Y.name());
    this.dataTypeId = JDBCUtils.safeGetInteger(dbResult, "DATATYPEID");
    this.sourceTypeId = JDBCUtils.safeGetInteger(dbResult, "SOURCETYPEID");
    this.createTime = JDBCUtils.safeGetTimestamp(dbResult, "CREATE_TIME");
    this.alterTime = JDBCUtils.safeGetTimestamp(dbResult, "ALTER_TIME");
    this.precision =
        DB2SequencePrecision.getFromDataType(JDBCUtils.safeGetInteger(dbResult, "PRECISION"));
    this.origin =
        CommonUtils.valueOf(DB2OwnerType.class, JDBCUtils.safeGetString(dbResult, "ORIGIN"));
    this.remarks = JDBCUtils.safeGetString(dbResult, "REMARKS");

    if (db2DataSource.isAtLeastV9_5()) {
      this.ownerType =
          CommonUtils.valueOf(DB2OwnerType.class, JDBCUtils.safeGetString(dbResult, "OWNERTYPE"));
    }
    if (db2DataSource.isAtLeastV9_7()) {
      this.baseSchema = JDBCUtils.safeGetStringTrimmed(dbResult, "BASE_SEQSCHEMA");
      this.baseSequence = JDBCUtils.safeGetString(dbResult, "BASE_SEQNAME");
    }
  }
  // ------------------------
  // Constructors
  // ------------------------
  public DB2CurrentUserPrivileges(
      DBRProgressMonitor monitor,
      JDBCSession session,
      String currentAuthId,
      DB2DataSource db2DataSource)
      throws SQLException {
    // DF: There is no easy way to get this information from DB2 v9.1
    // WE consider the user has no system authorities
    listAuthorities = new ArrayList<>();
    if (db2DataSource.isAtLeastV9_5()) {
      try (JDBCPreparedStatement dbStat = session.prepareStatement(SEL_AUTHORITIES)) {
        dbStat.setString(1, currentAuthId);
        try (JDBCResultSet dbResult = dbStat.executeQuery()) {
          while (dbResult.next()) {
            listAuthorities.add(dbResult.getString(1));
          }
        }
      }
    }

    listObjectPrivileges = new ArrayList<>();
    try (JDBCPreparedStatement dbStat = session.prepareStatement(SEL_OBJECTS)) {
      dbStat.setString(1, currentAuthId);
      dbStat.setString(2, currentAuthId);
      try (JDBCResultSet dbResult = dbStat.executeQuery()) {
        while (dbResult.next()) {
          listObjectPrivileges.add(dbResult.getString(1));
        }
      }
    }

    // Cache Authorities
    userIsAuthorisedForApplications = computeUserIsAuthorisedForApplications();
    userIsAuthorisedForDBCFG = computeUserIsAuthorisedForDBCFG();
    userIsAuthorisedForAdminister = userIsAuthorisedForApplications || userIsAuthorisedForDBCFG;

    userIsAuthorisedForContainers = computeUserIsAuthorisedForContainers();
  }