• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DATA RETREIVAL _ URGENT

 
jamuna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to retreive data from a table.the column type is decimal(8,2).it's an amount and I've inserted a value 123.45 in the table.when I try to retreive this value in the servlet and display using rs.getDouble("amount") it shows as 12345.0 .I'm using the mysql database.Could you please help me in fixing this problem.
Thanks,
Jams
 
Keith Cochran
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the short term, you can always divide the result by 100.
Make sure you're SQL is correct. It should look like:
INSERT INTO MyTable(dec_val) VALUES(123.45)
Try looking at the table using WinSQL or some other query tool
to make sure the db is storing the data correctly.
Keith
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JAMUNA
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jamuna:
I'm trying to retreive data from a table.the column type is decimal(8,2).it's an amount and I've inserted a value 123.45 in the table.when I try to retreive this value in the servlet and display using rs.getDouble("amount") it shows as 12345.0 .I'm using the mysql database.Could you please help me in fixing this problem.
Thanks,
Jams

My first guess is that the JDBC drive code you are using may
have a mistake If you have the source, check to see how the
getDouble is implemented. Or, get another driver for MySQL
(refer to mysql.org). I've had to fix JDBC source before.
Jim
 
Software Engg
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai jamunu,
Just check out b4 inserting nothing wrong in the code it should work fine
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Software Engg",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
This name is obviously a pseudonym, and will be turned off very soon. Please choose a new name immediately.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic