The moose likes JDBC and Relational Databases and the fly likes Oracle jdbc driver getColumnType return Number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Oracle jdbc driver getColumnType return Number " Watch "Oracle jdbc driver getColumnType return Number " New topic

Oracle jdbc driver getColumnType return Number

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi all
I have FLOAT column in my oracle db,
When calling ResultSetMetaData.getColumnType() I get java.sql.Types.NUMERIC; instead of java.sql.Types.FLOAT

What is the correct way to get the column type?

Stephan Mueller
Ranch Hand

Joined: May 05, 2010
Posts: 50
As far as I know, there is no FLOAT datatype in Oracle. They are using NUMBER (NUMERIC) which is the SQL-92 standard for numbers (decimals and floats, etc.)
You have to check the NUMERIC attributes to get an idea whether this should represent an Integer or not. For example NUMBER(10,7) is for a float/double.

Please refer to for Oracle's data-types (version 8-11g)
and for how to map datatypes.
Section 8.3.11 DECIMAL and NUMERIC:
The corresponding SQL types DECIMAL and NUMERIC are defined in SQL-92 and are very widely implemented. These SQL types take precision and scale parameters. The precision is the total number of decimal digits supported, and the scale is the number of decimal digits after the decimal point. For most DBMSs, the scale is less than or equal to the precision. So for example, the value "12.345" has a precision of 5 and a scale of 3, and the value ".11" has a precision of 2 and a scale of 2. JDBC requires that all DECIMAL and NUMERIC types support both a precision and a scale of at least 15.

1. Make it run - 2. Make it run correctly - 3. Make it pretty OR fast/small - 4. ??? - 5. Profit
I agree. Here's the link:
subject: Oracle jdbc driver getColumnType return Number
It's not a secret anymore!