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:
12: /**
13: * Keeps the meta data information of a column.
14: * This class is used by the H2 Console.
15: */
16: public class DbColumn {
17: String name;
18: String dataType;
19:
20: DbColumn(ResultSet rs) throws SQLException {
21: name = rs.getString("COLUMN_NAME");
22: String type = rs.getString("TYPE_NAME");
23: int size = rs.getInt("COLUMN_SIZE");
24: if (size > 0) {
25: type += "(" + size;
26: int prec = rs.getInt("DECIMAL_DIGITS");
27: if (prec > 0) {
28: type += ", " + prec;
29: }
30: type += ")";
31: }
32: if (rs.getInt("NULLABLE") == DatabaseMetaData.columnNoNulls) {
33: type += " NOT NULL";
34: }
35: dataType = type;
36: }
37: }
|