permaculture playing cards*
The moose likes JDBC and the fly likes different behavior with db2 driver, type 4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "different behavior with db2 driver, type 4" Watch "different behavior with db2 driver, type 4" New topic
Author

different behavior with db2 driver, type 4

Mette Russell
Greenhorn

Joined: May 07, 2008
Posts: 11
I have noticed a difference in data returned from the database, after having changed to a DB2 driver of type 4.

The most annoying change - and the one I would like some input on - is this:
My application is using Stored Procedures, so I'm using CallableStatement to call the Procedure.
Getting data out of the CallableStatement is done by using the different getXxx() methods.
When the java.sql.Types is either STRING or DECIMAL, the method getObject(index) is used.
This used to work perfectly with the previous driver, but has now changed radicaly with the type 4 driver.
When the return value is of type DECIMAL and > 0, the value in my object now has 8 zeroes after the decimal point (i.e. 6.00000000).
It used to be just the decimal (i.e. 6).
What is a lot worse is, that when the return value is of type DECIMAL and = 0, the value in my object is now 0E-8. It used to be 0.

Can anybody tell me why this is - or better - tell me how to get 'just' 0 instead of 0E-8?

Mette
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I'm guessing you are just calling toString() on the object returned? If you are you are at the mercy of the underlying method. Use a DecimalFormat instead.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mette Russell
Greenhorn

Joined: May 07, 2008
Posts: 11
Thanks.

Problem solved.
[ November 12, 2008: Message edited by: Mette Russell ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: different behavior with db2 driver, type 4
 
Similar Threads
Packed decimal conversion - Java
Urgent help - DB2 type 4 driver returns 0E-8 for decimal value
Type 2 and Type 4 Drivers for DB2
WebSphere Application Server Support Bulletin
Byte order!