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

Cannot store money value from Resultset

 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a query that is returning this value $129,194.11, the column in the table is of type money.

This is my query executed



In java i am declaring an array of doubles to store my values that I get from my queries



But when i get to this line... ' y[i] = R1.getDouble(1); ' I am getting this error....



CAN ANYBODY HELP AS I CANT FIGURE OUT WHAT AM I DOING WRONG..
thank you!!
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would imagine it's because the getDouble method cannot handle the comma in the value.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the data type of the column?

And, a double is a terrible choice for storing currency values.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the column has a comma in it, you should use rs.getString(). And then convert it to a BigDecimal; an actual money type
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for the help. I think the error was due because the column in my table was not set as as money type and not numeric.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic