My Oracle Support Banner

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

Last updated on AUGUST 19, 2020

Applies to:

JDBC - Version 9.2.0.1 to 10.2.0.1 [Release 9.2 to 10.2]
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

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

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


In this Document
Symptoms
Changes
Cause
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.