Objects DatabaseMetadata and ResultSetMetaData Return Different Values for Float DataType (Doc ID 816463.1)

Last updated on AUGUST 03, 2016

Applies to:

JDBC - Version: 9.2.0.1 to 10.2.0.1
Information in this document applies to any platform.

Symptoms

-- Problem Statement:
The objects DatabaseMetadata and ResultSetMetadata are returning different values for DATA_TYPE and TYPE_NAME in case of a data type FLOAT.

When running following code:
...
DatabaseMetaData databaseMetaData = connection.getMetaData();
ResultSet rsColumns = databaseMetaData.getColumns(null, null, "ALL_TYPES", null);

System.out.println("DatabaseMetaData:");
while (rsColumns.next()) {
  System.out.println("DATA_TYPE: "+rsColumns.getInt("DATA_TYPE"));
  System.out.println("COL_TYPENAME: "+rsColumns.getString("TYPE_NAME"));
}

...

ResultSet rs = connection.createStatement().executeQuery("select * from all_types");
ResultSetMetaData rsm = rs.getMetaData();

System.out.println("ResultSetMetaData:");
for(int i=1;i<=rsm.getColumnCount();i++){
  System.out.println("DATA_TYPE "+rsm.getColumnType(i));
  System.out.println("TYPE_NAME: "+rsm.getColumnTypeName(i));
}
...


The output is:
DatabaseMetaData:
DATA_TYPE: 6
TYPE_NAME : FLOAT

ResultSetMetadata:
DATA_TYPE: 2
TYPE_NAME: NUMBER

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms