Esempio n. 1
0
        /**
         * @param rs the ResultSet from a DatabaseMetaData.getColumns call
         */
        public JdbcColumnMetaData(JdbcTableMetaData table, ResultSet rs)

        {
            _table = table;

            // COLUMN_NAME
            _name = rs.getString(4);
            // DATA_TYPE
            _jdbcType = rs.getInt(5);
            // COLUMN_SIZE
            _length = rs.getInt(7);

            // NULLABLE
            _isNotNull = rs.getInt(11) == DatabaseMetaData.columnNoNulls;

            // TYPE_NAME
            string type = rs.getString(6).toLowerCase(Locale.ENGLISH);

            _isUnsigned = type.indexOf("unsigned") >= 0;
            _isZeroFill = type.indexOf("zerofill") >= 0;
        }
        /**
         * Returns the table metadata.
         */
        public JdbcTableMetaData getTableMetaData(Env env,
                                                  string catalog,
                                                  string schema,
                                                  string table)

        {
            try {
                if (table == null || table.equals(""))
                {
                    return(null);
                }

                TableKey key = new TableKey(getURL(), catalog, schema, table);

                // XXX: needs invalidation on DROP or ALTER
                JdbcTableMetaData tableMd = _tableMetadataMap.get(key);

                if (tableMd != null && tableMd.isValid(env))
                {
                    return(tableMd);
                }

                tableMd = new JdbcTableMetaData(env,
                                                catalog,
                                                schema,
                                                table,
                                                getMetaData());

                _tableMetadataMap.put(key, tableMd);

                return(tableMd);
            } catch (SQLException e) {
                log.log(Level.FINE, e.ToString(), e);

                return(null);
            }
        }