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

FORM 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
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to use getString() instead. You can then convert the value, if you need to use it in computations. If you just need to display it, getString() should do.
Bosun
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 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)

Heeya, Jams! That's no way of bargin' into the ranch just like bull with mad cow disease.
Yer name be too short for the rules we 'avin 'ere, son. And what's yer business asking y' questions thrice over. Wrong place, too, m'lad -- there ain't no servlet or JSP for an old cowboy to take a shot at.
If the ranch weren't such a friendly place, yer not be gettin' no answer at all that way!
The answer be in the java.sql.* JavaDoc, buddy. If y'don't know how to browse JavaDoc, you haven't got no business operating a compiler. But alright, we've all been young and rash, and -- aw, I'm ramblin' again.
The SQL DECIMAL and NUMERIC data types are used to express fixed point numbers where absolute precision is required. They are often used for currency values.
These two types can be expressed identically in Java. The most convenient mapping uses the java.math.BigDecimal extended precision number type provided in JDK1.1
We also allow access to DECIMAL and NUMERIC as simple Strings and arrays of chars. Thus Java programmers can use getString to receive a NUMERIC or DECIMAL result.

That's what section 8.4 of the JDBC Guide says, which is where the java.sql package description tells ya to look.
Heeya!
- Peter
 
jamuna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys.peter,you should have given a one line suggestion instead of typing 1 page.how rude???
 
Randall Twede
Ranch Hand
Posts: 4489
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jamuna,
I think this is one line:
Your name does not comply with the Javaranch naming guidelines which can be found at http://www.javaranch.com/name.jsp please register again with a valid name.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jamuna:
thanks guys.peter,you should have given a one line suggestion instead of typing 1 page.how rude???

Hmmm, I thought I had the tongue quite evidently in cheek this time. Next time I'll liberally use smileys
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic