This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle jdbc driver getColumnType return Number " Watch "Oracle jdbc driver getColumnType return Number " New topic
Author

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 http://ss64.com/ora/syntax-datatypes.html for Oracle's data-types (version 8-11g)
and http://download.oracle.com/javase/1.3/docs/guide/jdbc/getstart/mapping.html 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: http://aspose.com/file-tools
 
subject: Oracle jdbc driver getColumnType return Number
 
Similar Threads
java.sql.Timestamp to Oracle date
How to get the first 255 characters?
Error while retrieving blob images
Oracle Null Value
Seperating data