File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\server\web\DbColumn.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.server.web;
8
9 import java.sql.DatabaseMetaData;
10 import java.sql.ResultSet;
11 import java.sql.SQLException;
12
13 /**
14 * Keeps the meta data information of a column.
15 * This class is used by the H2 Console.
16 */
17 class DbColumn {
18
19 /**
20 * The column name.
21 */
22 final String name;
23
24 /**
25 * The quoted table name.
26 */
27 final String quotedName;
28
29 /**
30 * The data type name (including precision and the NOT NULL flag if
31 * applicable).
32 */
33 final String dataType;
34
35 DbColumn(DbContents contents, ResultSet rs) throws SQLException {
36 name = rs.getString("COLUMN_NAME");
37 quotedName = contents.quoteIdentifier(name);
38 String type = rs.getString("TYPE_NAME");
39 int size = rs.getInt(DbContents.findColumn(rs, "COLUMN_SIZE", 7));
40 boolean isSQLite = contents.isSQLite;
41 if (size > 0 && !isSQLite) {
42 type += "(" + size;
43 int prec = rs.getInt(DbContents.findColumn(rs, "DECIMAL_DIGITS", 9));
44 if (prec > 0) {
45 type += ", " + prec;
46 }
47 type += ")";
48 }
49 if (rs.getInt("NULLABLE") == DatabaseMetaData.columnNoNulls) {
50 type += " NOT NULL";
51 }
52 dataType = type;
53 }
54 }
55