Пример #1
0
  private static void printHeader() {

    if (printedHeader) return;

    Logs.reportString("----------------------------------------------");
    Logs.reportMessage("DBLOOK_KeysHeader");
    Logs.reportString("----------------------------------------------\n");
    printedHeader = true;
  }
Пример #2
0
  private static void createKeysFrom(ResultSet rs) throws SQLException {

    boolean firstTime = true;
    while (rs.next()) {

      if (!rs.getBoolean(7))
        // this row is NOT for a constraint, so skip it.
        continue;

      String tableId = rs.getString(3);
      String tableName = dblook.lookupTableId(tableId);
      if (dblook.isExcludedTable(tableName))
        // table isn't included in user-given list; skip it.
        continue;

      if (firstTime) {
        printHeader();
        if (rs.getString(2).equals("F")) Logs.reportMessage("DBLOOK_ForeignHeader");
        else Logs.reportMessage("DBLOOK_PrimUniqueHeader");
      }

      StringBuffer kString = createKeyString(tableId, tableName, rs);

      if (rs.getString(2).equals("F")) {
        // foreign key; we have to figure out the references info.
        kString.append(
            makeFKReferenceClause(
                rs.getString(10), rs.getString(8).charAt(0), rs.getString(9).charAt(0)));
      }

      Logs.writeToNewDDL(kString.toString());
      Logs.writeStmtEndToNewDDL();
      Logs.writeNewlineToNewDDL();
      firstTime = false;
    }

    return;
  }