{
/* NOTE: there are two rows.
* NOTE: MssqlConstraint holds the columns in the table participating in the key.
* NOTE: ForeignKeyConstraint holds the columns in the referenced table IN THE SAME ORDER.
*/
ForeignKeyConstraint fk = new ForeignKeyConstraint();
fk.setConstraintName(constraintName);
String foreignColumns[] = constraintKeys.split(", ");
for (int i = 0; i < foreignColumns.length; i++)
fk.addConstraintColumn(foreignColumns[i]);
rs.next();
constraintKeys = rs.getString(7);
// constraintKeys looks like this --> `REFERENCES pubs.dbo.foo (fooid, quuxid)'
constraintKeys = constraintKeys.substring(11); // chop off "REFERENCES "
String[] tableAndColumns = constraintKeys.split(" ", 2);
// now tableAndColumns[0] contains the table name and tableAndColumns[1] contains
// the bracketed list of columns.
fk.setReferencedTable(tableAndColumns[0]);
String primaryColumns[] =
tableAndColumns[1].substring(1, tableAndColumns[1].length() - 2).split(",");
for (int i = 0; i < primaryColumns.length; i++)
fk.addPrimaryColumn(primaryColumns[i]);
constraints.addConstraint(fk);
}
else if (constraintType.startsWith("PRIMARY KEY"))
{