Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatement.setFloat not entering precise values in db

 
java dunce
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have written a program where I am entering a record in to the
database using a prepared statement. The problem is for float datatypes, the
values being entered into the database are not rounded off. e.g. 1.65 is
being entered as 1.64999999
I am using the Sybase database and the driver is
com.sybase.jdbc2.jdbc.SybDriver.

If I use staement instead of prepared statement, i am getting the correct values.
Regards
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the two code fragments you're using?
Make sure you use the UBB CODE tags.

Thanks

Jules
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"java dunce",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic