• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retriving data with four decimal places

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a problem in retriving data with four decimal places from database.
I was using rs.getDouble() method. But this gives me only 2 decimal places on the result. Which is the best method to be used to retrive 4 decimal places. Thanks in advance.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ajith,

Firstly, the thing that can affect your output may be one or combination of the following:

  • the JDBC driver itself that you are using, i.e., MySQL, PostgreSQL, Cloudscape, etc.
  • Or the number of decimal places defined in your table


  • If your column is defined to have two (2) decimal places, say , then no matter what value you get - you'll always get N.NN.

    Likewise, if your column is defined to have four decimal places, say , then no matter what value you get - you'll always get N.NNNN.

    But somehow, if you use , then you'll be able to get a value in N.NNNN, no matter how many decimal places you've defined in your column.

    You may consider the following code for illustration (although there might be some other best solution for your case):


    Originally posted by Ajith George:
    I was using rs.getDouble() method. But this gives me only 2 decimal places on the result. Which is the best method to be used to retrive 4 decimal places. Thanks in advance.


    [ March 29, 2006: Message edited by: Eduardo Dela Rosa ]
    [ March 29, 2006: Message edited by: Eduardo Dela Rosa ]
     
    Ajith George
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for your reply. I think this will solve my problem.
     
    We can walk to school together. And we can both read this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic