What Java data type corresponds to the Oracle SQL data type NUMERIC? What Java data type corresponds to the Oracle SQL data type NUMERIC? oracle oracle

What Java data type corresponds to the Oracle SQL data type NUMERIC?


As others have already said: the driver maps everything to BigDecimal, even if it's defined as NUMBER(38) (which could be mapped to BigInteger)

But it's pretty easy to find out what the driver maps. Simply do a getObject() on the column of the ResultSet and see which class the driver generated.

Something like:

ResultSet rs = statement.executeQuery("select the_number_column from the_table");if (rs.next()){  Object o = rs.getObject(1);  System.out.println("Class: " + o.getClass().getName());}


According to the Oracle documentation it is java.math.BigDecimal.


"but my cast to BigDecimal throws a ClassCastException"

Have you tried using oracle.sql.NUMBER ?


It's been a while, but I believe it's BIGINT in Java.It's BigDecimal. I remember the classcastexception you'd encounter would give a hint...