/** * Gets all catalogs for this database keyed by unique name. * * @see java.sql.DatabaseMetaData#getCatalogs() */ public SortedMap<String,Catalog> getCatalogs() throws SQLException { synchronized(getCatalogsLock) { if(getCatalogsCache==null) { SortedMap<String,Catalog> newCatalogs = new TreeMap<>(englishCollator); try (ResultSet results = metaData.getCatalogs()) { while(results.next()) { Catalog newCatalog = new Catalog(this, results.getString(1)); if(newCatalogs.put(newCatalog.getName(), newCatalog)!=null) throw new AssertionError("Duplicate catalog: "+newCatalog); } } getCatalogsCache = AoCollections.optimalUnmodifiableSortedMap(newCatalogs); } return getCatalogsCache; } }
getSchemasCache = AoCollections.optimalUnmodifiableSortedMap(newSchemas);
/** * Gets all tables for this schema keyed by unique name. * * @see java.sql.DatabaseMetaData#getTables() */ public SortedMap<String,Table> getTables() throws SQLException { synchronized(getTablesLock) { if(getTablesCache==null) { SortedMap<String,Table> newTables = new TreeMap<>(DatabaseMetaData.getCollator()); try (ResultSet results = catalog.getMetaData().getMetaData().getTables(catalog.getName(), name, null, null)) { while(results.next()) { Table newTable = new Table(this, results.getString("TABLE_NAME"), results.getString("TABLE_TYPE")); if(newTables.put(newTable.getName(), newTable)!=null) throw new AssertionError("Duplicate table: "+newTable); } } getTablesCache = AoCollections.optimalUnmodifiableSortedMap(newTables); } return getTablesCache; } }
getColumnMapCache = AoCollections.optimalUnmodifiableSortedMap(newColumnMap);