Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DB2 DECIMAL FORMAT EXCEPTION (URGENT)

843854Nov 14 2002 — edited Nov 21 2002
To undersdande my problem, please see the code below:

CODE A:
sql = "INSERT INTO DEC VALUES ('999999999999999.99',999999999999999.99')";
PreparedStatement stmt = con.getConnection().prepareStatement(sql);
stmt.executeUpdate();

CODE B:
sql = "INSERT INTO DEC VALUES (?, ?)";
PreparedStatement stmt = con.getConnection().prepareStatement(sql);
stmt.setString(1, '999999999999999.99');
stmt.setDouble(2, 999999999999999.99);
stmt.executeUpdate();

The Problem:

The table DEC tha I used has two columns, the first is a char(50) and the second is a Decimal(17,2) and its in DB2 running on AIX.

If I execute the firs statement, it execute very well. If I execute the second, the follow exception occurs:

COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use. SQLSTATE=22003

If I reduce on algarism on number (14 digits and two decimals) the result is:
String Decimal
-------------------------------------
CODE A 99999999999999.99, 99999999999999.99
CODE B 99999999999999.99, 100000000000000.00

My question:
Is the code incompatible? Why?
Does anybody knows what is wrong?

I need help urgent!!!

Thanks in advance

Renato Melo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 19 2002
Added on Nov 14 2002
2 comments
338 views