This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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
Joined: Feb 20, 2001
Posts: 4
posted
0
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
Joined: May 05, 2000
Posts: 13974
posted
0
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.
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
Joined: Feb 19, 2001
Posts: 10
posted
0
hai jamunu, Just check out b4 inserting nothing wrong in the code it should work fine
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
"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.