This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes calculation on data retrieved from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "calculation on data retrieved from database" Watch "calculation on data retrieved from database" New topic
Author

calculation on data retrieved from database

Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

problem in retrieving data from database
i want to do calculation on data retrieved from database
first two rows it prints perfectly but after that it terminates where calculation starts


i don't know what i am doing wrong


Don't aim for success if you want it; just do what you love and believe in, and it will come naturally.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42360
    
  64
What does "it terminates" mean? What is or isn't executed? Are there any error messages in the log files?


Ping & DNS - my free Android networking tools app
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

this not throwing any exceptions
it terminates where the callculations start
see output

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42360
    
  64
this not throwing any exceptions

Are you sure about that? There isn't an empty catch block somewhere, is there?

Does the ResultSet contain a column called "discount"?

By the way, you should never do calculations involving amounts of money using integers (or floats or doubles); use BigDecimal instead.
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

Are you sure about that?

yes i am sure.there is no empty catch block there
there is column in my database called discount
from where i am retrieving value
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

problem is solved
i have two catch blocks in my code with same objects like this
i change

to


and it works
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calculation on data retrieved from database