Package henplus.sqlmodel

Examples of henplus.sqlmodel.PrimaryKey


            throws SQLException {

        Table table = null;
        if (rset != null) {
            table = new Table(tableName);
            final PrimaryKey pk = getPrimaryKey(meta, tableName);
            final Map<String, ColumnFkInfo> fks = getForeignKeys(meta, tableName);
            // what about the following duplicate?
            // rset = meta.getColumns(catalog, null, tableName, null);
            while (!_interrupted && rset.next()) {
                final String colname = rset.getString(COLUMN_NAME);
                final Column column = new Column(colname);
                column.setType(rset.getString(TYPE_NAME));
                column.setSize(rset.getInt(COLUMN_SIZE));
                final boolean nullable = rset.getInt(NULLABLE) == DatabaseMetaData.columnNullable ? true : false;
                column.setNullable(nullable);
                final String defaultVal = rset.getString(COLUMN_DEF);
                column.setDefault(defaultVal != null ? defaultVal.trim() : null);
                column.setPosition(rset.getInt(ORDINAL_POSITION));
                column.setPkInfo(pk.getColumnPkInfo(colname));
                column.setFkInfo(fks.get(colname));

                table.addColumn(column);
            }
            rset.close();
View Full Code Here


        }
        return table;
    }

    private PrimaryKey getPrimaryKey(final DatabaseMetaData meta, final String tabName) throws SQLException {
        PrimaryKey result = null;
        final ResultSet rset = meta.getPrimaryKeys(null, null, tabName);
        if (rset != null) {
            result = new PrimaryKey();
            String pkname = null;
            while (rset.next()) {
                final String col = rset.getString(PK_DESC_COLUMN_NAME);
                pkname = rset.getString(PK_DESC_PK_NAME);
                final int pkseq = rset.getInt(PK_DESC_KEY_SEQ);
                result.addColumn(col, pkname, pkseq);
            }
            rset.close();
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of henplus.sqlmodel.PrimaryKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.