Iterator i = tables.iterator(); while (i.hasNext()) { Table t = (Table) i.next(); Iterator columnIterator = getColumnsForTable(t.getName()).iterator(); while (columnIterator.hasNext()) { t.addColumn((Column) columnIterator.next());
for (Iterator it = tables.iterator(); it.hasNext();) { Table table = (Table)it.next();  for (Iterator columnIt = getColumnsForTable(table.getName()).iterator(); columnIt.hasNext();) { table.addColumn((Column)columnIt.next());
    public List getTables() throws SQLException {        List tableInfoColumns = new Vector();        DatabaseMetaData dbmd = connection.getMetaData();        ResultSet tableData = null;        List tables = new Vector();        // these are the entity types we want from the database        try {            tableData = dbmd.getTables(catalog, schema, "%", tableTypes);            // This is to protect against databases that dont support all fields            // expected from the getTables query            ResultSetMetaData rsmd = tableData.getMetaData();            for (int i = 0; i < rsmd.getColumnCount(); i++) {                tableInfoColumns.add(rsmd.getColumnName(i + 1));            }            while (tableData.next()) {                /* table catalog (may be null) */                String tableCatalog =                    tableInfoColumns.contains("TABLE_CAT")                        ? tableData.getString("TABLE_CAT")                        : "";                /* table schema (may be null) */                String tableSchema =                    tableInfoColumns.contains("TABLE_SCHEM")                        ? tableData.getString("TABLE_SCHEM")                        : "";                /* table name */                String tableName =                    tableInfoColumns.contains("TABLE_NAME")                        ? tableData.getString("TABLE_NAME")                        : "";                /*                  * table type.                   * Typical types are "TABLE", "VIEW", "SYSTEM TABLE",                  * "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".                 */                String tableType =                    tableInfoColumns.contains("TABLE_TYPE")                        ? tableData.getString("TABLE_TYPE")                        : "UNKNOWN";                /* explanatory comment on the table */                String tableRemarks =                    tableInfoColumns.contains("REMARKS")                        ? tableData.getString("REMARKS")                        : "";                /* the types catalog (may be null) */                String tableTypeCatalog =                    tableInfoColumns.contains("TYPE_CAT")                        ? tableData.getString("TYPE_CAT")                        : null;                /* the types schema (may be null) */                String tableTypeSchema =                    tableInfoColumns.contains("TYPE_SCHEM")                        ? tableData.getString("TYPE_SCHEM")                        : null;                /* type name (may be null) */                String tableTypeName =                    tableInfoColumns.contains("TYPE_NAME")                        ? tableData.getString("TYPE_NAME")                        : null;                /* name of the designated "identifier" column of a typed table (may be null) */                String tableSelfRefColName =                    tableInfoColumns.contains("SELF_REFERENCING_COL_NAME")                        ? tableData.getString("SELF_REFERENCING_COL_NAME")                        : null;                /*                  * specifies how values in SELF_REFERENCING_COL_NAME are created.                 * Values are "SYSTEM", "USER", "DERIVED". (may be null)                      */                String tableRefGeneration =                    tableInfoColumns.contains("REF_GENERATION")                        ? tableData.getString("REF_GENERATION")                        : null;                Table t1 = new Table();                t1.setName(tableName);                t1.setType(tableType);                tables.add(t1);            }            Iterator i = tables.iterator();            while (i.hasNext()) {                Table t = (Table) i.next();                Iterator columnIterator =                    getColumnsForTable(t.getName()).iterator();                while (columnIterator.hasNext()) {                    t.addColumn((Column) columnIterator.next());                }                Iterator fkIterator =                    getForeignKeysForTable(t.getName()).iterator();                while (fkIterator.hasNext()) {                    t.addForeignKey((ForeignKey) fkIterator.next());                }                Iterator idxIterator =                    getIndexesForTable(t.getName()).iterator();                while (idxIterator.hasNext()) {                    t.addIndex((Index) idxIterator.next());                }            }            return tables;        }        finally {            if (tableData != null) {                tableData.close();            }        }    }