• 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

Apache Derby data base DECIMAL converting to BigDecimal

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I extract a inserted record(apache Derby embeded db) to view it I load a DECIMAL datatype of 100.00 from the database to the controller variable payRate with data type BigDecimal.

The database loads a BIGDECIMAL from this controller just fine. but the data type is noted as DECIMAL(5,2) in the table createion. Is there a code example other than the API that could explain how to store 100.00 (DECIMAL from the database) to a data Type

BIGDECIMAL In the controller. Does a scale have to be established or some kind of rounding of the
value coming from database have to happen? I can not understand the rounding or mathContext() descriptions in Class BigDecimal or Enum Rounding Class.

I can not understan why the data types are compatable on insert but if I pull the value out
It will not load the same vaiable.

Before the insert the bean contains: Data type= BigDecimal



The bean value is inserted into the table of data type:





result output :inserted into database (apache derby embedded)



when I then select the record back out to look at it:




When I extract the same record to view it I load a controller




my application at this early stage will not deal with any complex math.everything is rounded
to two decimal places ex(25.00)

I probably should change the data types to BIGINT (apache derby)

is there a way to continue with BIGDECIMAL? Would there be any advantage later if the math gets more complex? Or would BIGINT handle the basics?








 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, regardless of all that, there's a good chance that "rs.getBigDecimal(12)" is just attempting to get data from some other field because you miscounted your columns. However you didn't post the query so it's impossible for anybody but you to confirm that.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll move this thread to our JDBC forum.
 
Steve Howerton
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I Looked at it fresh this morning and clearly the SELECT statement (above) indeed it is
trying to load rs.getBigDecimal(12) by accessing the admin_area_code field. So I will
stick with BIGDECIMAL. I am not certain but in my limited understanding of the math concepts
of BIGINT and BIGDECIMAL and the math I may inject into the App. I am under the impression
that BIGDECIMAL will handle a wider variety of mathematical calculations.
Thanks for your time.






output of the bean contents:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic