}
private Table buildTable(final String catalog, final DatabaseMetaData meta, final String tableName, final ResultSet rset)
throws SQLException {
Table table = null;
if (rset != null) {
table = new Table(tableName);
final PrimaryKey pk = getPrimaryKey(meta, tableName);
final Map<String, ColumnFkInfo> fks = getForeignKeys(meta, tableName);
// what about the following duplicate?
// rset = meta.getColumns(catalog, null, tableName, null);
while (!_interrupted && rset.next()) {
final String colname = rset.getString(COLUMN_NAME);
final Column column = new Column(colname);
column.setType(rset.getString(TYPE_NAME));
column.setSize(rset.getInt(COLUMN_SIZE));
final boolean nullable = rset.getInt(NULLABLE) == DatabaseMetaData.columnNullable ? true : false;
column.setNullable(nullable);
final String defaultVal = rset.getString(COLUMN_DEF);
column.setDefault(defaultVal != null ? defaultVal.trim() : null);
column.setPosition(rset.getInt(ORDINAL_POSITION));
column.setPkInfo(pk.getColumnPkInfo(colname));
column.setFkInfo(fks.get(colname));
table.addColumn(column);
}
rset.close();
}
return table;
}