logger.finest(mName, "Looking for foreign keys of " + pTable + "=" + pTable.getTable().getQName());
List result = new ArrayList();
ResultSet rs = pData.getImportedKeys(pTable.getCatalogName(),
pTable.getSchemaName(),
pTable.getTableName());
ForeignKey foreignKey = null;
boolean isRsClosed = false;
try {
while (rs.next()) {
JDBCTable referencedTable = new JDBCTable(rs.getString(1), rs.getString(2),
rs.getString(3), "TABLE");
String referencedColumnName = rs.getString(4);
String localColumnName = rs.getString(8);
logger.finest(mName, "Found column " + localColumnName + " referencing " +
referencedColumnName + " in " + referencedTable);
for (int i = 0; i < pTables.length; i++) {
JDBCTable refIterTable = pTables[i];
if (refIterTable.equals(referencedTable)) {
referencedTable.setTable(refIterTable.getTable());
break;
}
}
if (referencedTable.getTable() == null) {
logger.finest(mName, "Unknown table, ignoring");
continue;
}
short seq = rs.getShort(9);
if (seq == 1) {
foreignKey = pTable.getTable().newForeignKey(referencedTable.getTable());
result.add(foreignKey);
}
foreignKey.addColumnLink(localColumnName, referencedColumnName);
}
isRsClosed = true;
rs.close();
} finally {