Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Retrieving BigDecimal value from Netezza DB using JDBC  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to retrieve a BigDecimal value from Netezza database using jdbc, in my machine it works
in another machine it displays only the digits before the decimal point

for ex : 1.08765678 is a BigDecimal value from DB

and I do

value=rs.getBigDecimal("column_name");

I am getting 1.08765678 ( my machine has JDK_VERSION = 1.7.0_40)

but in another machine it is displaying as 1 ( the other machine has Java Version: 1.6.0_45)

please help

I also tried rs.getBigDecimal("column_name").setScale(7)

 
Marshal
Posts: 60108
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You appear to have landed in the wrong forum; I shall move you to our database forum.
Don't know. Sorry. You do realise that JDK1.7.0_40 is out of date; use this.
 
author & internet detective
Sheriff
Posts: 38564
654
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

Your Java code to get the BigDecimal is correct. Can you show how you are printing out the BigDecimal?
 
subhasri paulmony
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am getting like this

BigDecimal adjustmentFactor;
StringBuffer sb = new StringBuffer(512);

adjustmentFactor=rs.getBigDecimal("ADJUSTMENT_FACTOR")
sb.append(String.format("%-9s",String.valueOf(adjustmentFactor)));
 
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like something changed between Java 6 and Java 7. However you have a bunch of things going on there -- database access and string formatting at least -- which makes it hard to pinpoint the problem.

So try taking out the database access; replace that code by something which just assigns a hard-coded BigDecimal value and formats it, and see if the problem persists.
 
subhasri paulmony
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is even before formatting

I ran the application in debug mode and in the below line

adjustmentFactor=rs.getBigDecimal("ADJUSTMENT_FACTOR")

when I check the value of adjustmentFactor after the assignment (in debug mode), only value "1" is stored in it. but the actual value from the database is 1.08765678
 
Paul Clapham
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you have isolated the problem. That's a good first step. Now, you said that one version of the code used Java 6 and the other used Java 7. That's a possible source of differences but there could be others. A more relevant question would be, are they using the same version of the JDBC driver?
 
subhasri paulmony
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this seems to be an issue with the nzjdbc.jar (Release 4.6.5 driver [build 10670])


I tried with the most recent version of the jar (NPS 7.02 P11) and it is working now

thank you very much for your earlier responses
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!