从DatabaseMetaData.getColumns()中缺少列

时间:2016-09-19 16:03:14

标签: java oracle jdbc database-metadata

DatabaseMetaData.getColumns()的Java 7 Javadoc表示它返回一个包含24列的 ResultSet ,第一列名为 TABLE_CAT ,最后一列命名为 IS_GENERATEDCOLUMN 。但是,我从Oracle收到的结果集只有18列。我使用以下代码验证了它:

DatabaseMetaData databaseMetaData = connection.getMetaData();
ResultSet set = databaseMetaData.getColumns(catalogName, schemaPattern,
        tableNamePattern, columnNamePattern);
final ResultSetMetaData resultSetData = set.getMetaData();
final int columnCount = resultSetData.getColumnCount();

for (int columnIndex = 1; columnIndex <= columnCount; ++columnIndex) {
   final String columnName = resultSetData.getColumnName(columnIndex);
   System.out.printf("Column %d: %s%n", columnIndex, columnName);
}

上面的代码产生了这个输出:

Column 1: TABLE_CAT
Column 2: TABLE_SCHEM
Column 3: TABLE_NAME
Column 4: COLUMN_NAME
Column 5: DATA_TYPE
Column 6: TYPE_NAME
Column 7: COLUMN_SIZE
Column 8: BUFFER_LENGTH
Column 9: DECIMAL_DIGITS
Column 10: NUM_PREC_RADIX
Column 11: NULLABLE
Column 12: REMARKS
Column 13: COLUMN_DEF
Column 14: SQL_DATA_TYPE
Column 15: SQL_DATETIME_SUB
Column 16: CHAR_OCTET_LENGTH
Column 17: ORDINAL_POSITION
Column 18: IS_NULLABLE

为什么我不能获得所有24列?我错过了什么?

0 个答案:

没有答案