• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FORM DATA RETREIVAL URGENT

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys.peter,you should have given a one line suggestion instead of typing 1 page.how rude???
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic