File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes BigDecimal value from a Double Value ERROR 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 "BigDecimal value from a Double Value ERROR" Watch "BigDecimal value from a Double Value ERROR" New topic

BigDecimal value from a Double Value ERROR

steve hoover

Joined: Feb 07, 2003
Posts: 2
I am using Jbuilder 6.
We recently upgraged our Oracle Database from to
Ever since the upgrade I have been unable to select a sequence value from my database within my java application.
Here is the line of code that is failing: dataSet.setBigDecimal(primaryKeyName,sequenceGeneratorQueryDataSet.getBigDecimal("SEQ_NUM"));
I get the following error:
Attempt to get a BIGDECIMAL value from a DOUBLE value.
The only changes that have occured in the databse was the previously mentioned database upgrade.
Has anyone else had this problem?
I have been looking at the patchsets' readme file but have not found what could have caused the problem.
Any Ideas anyone?
steve hoover

Joined: Feb 07, 2003
Posts: 2
For those that are interested.
I logged a TAR with Oracle and found out the following:
This is from Oracle:
Starting on JDBC there has been a change of behaviour on the datatype returned from getMetaData() in jdbc.
If Oracle returns a NUMBER datatype to JDBC. The results of the datatype type output are different in than in
This change of behaviour is experienced using JDBC THIN or OCI and independent to what version of the database they connect to.
In 8i and, A number datatype was mapped to: java type of: java.math.BigDecimal
in 9014, 9202 and 10i, A number datatype is mapped to : java.lang.Integer
According to java, sql datatype mappings table documented on the JDBC developers guide and reference:
Table 20-1 Valid SQL Datatype-Java Class Mappings .
See 3.0 JDBC spec,
From the JDBC spec 3.0 API Table B3 " Mapping from JDBC types to Java Object Types"
JDBC type Java Object type
In this case we are register the JDBC type to be of type java.sql.Integer, by using registerOutParameter(1, java.sql.Types.INTEGER).
So, the 9014, 92 is the correct behavior.
The old behavior (8i to 9013) was violating the jdbc 3.0 spec and the new behvior is the correct one as required by J2EE CTS (JAVA Certification Suite for J2EE complient), for that reason Oracle integrated a set of changes on their version of the driver and above.
Please note that JDBC 9013 can still be used with 920X database. As this configuration was done for our iAS product.
As a result I had to remove the following call:
and replace it with :
Statement stmt;
Connection conn = sTEPDataModule.getDatabase().getJdbcConnection();
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery( "select "+sequenceGeneratorName+".nextval SEQ_NUM from dual");;
This seems to work with no problems.
I agree. Here's the link:
subject: BigDecimal value from a Double Value ERROR
It's not a secret anymore!