01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.server.web;
07:
08: import java.sql.DatabaseMetaData;
09: import java.sql.ResultSet;
10: import java.sql.SQLException;
11: import java.util.ArrayList;
12:
13: /**
14: * Contains meta data information about a database schema.
15: * This class is used by the H2 Console.
16: */
17: public class DbSchema {
18: DbContents contents;
19: String name;
20: String quotedName;
21:
22: DbTableOrView[] tables;
23: public boolean isDefault;
24:
25: DbSchema(DbContents contents, String name, boolean isDefault)
26: throws SQLException {
27: this .contents = contents;
28: this .name = name;
29: this .quotedName = contents.quoteIdentifier(name);
30: this .isDefault = isDefault;
31: }
32:
33: public void readTables(DatabaseMetaData meta, String[] tableTypes)
34: throws SQLException {
35: ResultSet rs = meta.getTables(null, name, null, tableTypes);
36: ArrayList list = new ArrayList();
37: while (rs.next()) {
38: DbTableOrView table = new DbTableOrView(this , rs);
39: if (contents.isOracle && table.name.indexOf('$') > 0) {
40: continue;
41: }
42: list.add(table);
43: }
44: rs.close();
45: tables = new DbTableOrView[list.size()];
46: list.toArray(tables);
47: if (tables.length < 100) {
48: for (int i = 0; i < tables.length; i++) {
49: DbTableOrView tab = tables[i];
50: tab.readColumns(meta);
51: }
52: }
53: }
54:
55: }
|