I'm using Oracle's JDBC thin driver (10.2.0.3) for connecting to an Oracle 10g database. I'd like to get information about the database columns, so I use ResultSetMetaData. The most important information I need is the type of the column and the length, so I use getColumnType, getPrecision, and getScale methods.
It works for a simple query (select * from tablename
) if the column type is "simple" like VARCHAR2(50), NUMBER(5), NUMBER(6,2)
. If I have a more complex query (select count(*) from tablename
) or a query based on a view which contains some complex calculation, the methods give weird results like:
getScale
: -127- both
getPrecision
andgetScale
is 0 getPrecision
: -1
Setting the oracle.jdbc.J2EE13Compliant
connection property to true
(as suggested by several webpages) eliminates getScale=-127 but still returns 0/0 result.
Most likely I have to create a workaround for these weird results, but first I need at least a comprehensive documentation about the behavior of Oracle's ResultSetMetaData. For instance a huge table with the meaning of getPrecision/getScale for all the SQL types would be great. Is there a documentation like this somewhere?