This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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: 62216
193
  • 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
Posts: 39054
714
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: 23965
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: 23965
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
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!