String tableName = fk[j].getForeignTableName();
if (tableName!=null) {
if (tableName.toLowerCase().equals(table.getName().toLowerCase())) {
ref = fk[j].getReference(0);
columnRef = ref.getLocalColumnName();
Column column = ColumnUtils.getColumn (tables[i], ref.getLocalColumnName());
//reference = new Reference(tables[i], column2, tables[i].getName(), ref.getLocalColumnName());
//org.apache.ddlutils.model.ForeignKey foreignKeyddlutils = tables[i].getForeignKeys()[j].getFirstReference();
//org.apache.ddlutils.model.Reference referenceddlutils = foreignKeyddlutils.getFirstReference();
reference = tables[i].getForeignKeys()[j].getFirstReference();
//reference = new ReferenceDDLUtils (new org.apache.ddlutils.model.Reference ());
reference.setForeignColumn(column);
reference.setForeignColumnName(column.getName());
reference.setForeignTable(tables[i]);
reference.setForeignTableName(tables[i].getName());
//ColumnDDLUtils localCol = (ColumnDDLUtils)TableUtils.getPrimaryFirstColumn(new TableDDLUtils(table));
//ColumnDDLUtils columnLoc = new ColumnDDLUtils(localCol, new TableDDLUtils(table));
reference.setLocalColumn(TableUtils.getPrimaryFirstColumn(new TableDDLUtils(table)));