• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

different behavior with db2 driver, type 4

 
Mette Russell
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mette Russell
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

Problem solved.
[ November 12, 2008: Message edited by: Mette Russell ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic