KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > server > web > DbTableOrView


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.server.web;
6
7 import java.sql.DatabaseMetaData JavaDoc;
8 import java.sql.ResultSet JavaDoc;
9 import java.sql.SQLException JavaDoc;
10 import java.util.ArrayList JavaDoc;
11
12 public class DbTableOrView {
13     DbSchema schema;
14     String JavaDoc name;
15     String JavaDoc quotedName;
16     boolean isView;
17     DbColumn[] columns;
18     
19     DbTableOrView(DbSchema schema, ResultSet JavaDoc rs) throws SQLException JavaDoc {
20         this.schema = schema;
21         name = rs.getString("TABLE_NAME");
22         String JavaDoc type = rs.getString("TABLE_TYPE");
23         isView = "VIEW".equals(type);
24         quotedName = schema.contents.quoteIdentifier(name);
25     }
26     
27     public void readColumns(DatabaseMetaData JavaDoc meta) throws SQLException JavaDoc {
28         ResultSet JavaDoc rs = meta.getColumns(null, schema.name, name, null);
29         ArrayList JavaDoc list = new ArrayList JavaDoc();
30         while(rs.next()) {
31             DbColumn column = new DbColumn(rs);
32             list.add(column);
33         }
34         rs.close();
35         columns = new DbColumn[list.size()];
36         list.toArray(columns);
37     }
38
39 }
40
Popular Tags