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 table or a view.
15: * This class is used by the H2 Console.
16: */
17: public class DbTableOrView {
18: DbSchema schema;
19: String name;
20: String quotedName;
21: boolean isView;
22: DbColumn[] columns;
23:
24: DbTableOrView(DbSchema schema, ResultSet rs) throws SQLException {
25: this .schema = schema;
26: name = rs.getString("TABLE_NAME");
27: String type = rs.getString("TABLE_TYPE");
28: isView = "VIEW".equals(type);
29: quotedName = schema.contents.quoteIdentifier(name);
30: }
31:
32: public void readColumns(DatabaseMetaData meta) throws SQLException {
33: ResultSet rs = meta.getColumns(null, schema.name, name, null);
34: ArrayList list = new ArrayList();
35: while (rs.next()) {
36: DbColumn column = new DbColumn(rs);
37: list.add(column);
38: }
39: rs.close();
40: columns = new DbColumn[list.size()];
41: list.toArray(columns);
42: }
43:
44: }
|