Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retriving data with four decimal places

 
Ajith George
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • 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.
 
Eduardo Dela Rosa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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
    • Quote
    • Report post to moderator
    Thanks for your reply. I think this will solve my problem.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic