File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQL ResultSet error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL ResultSet error" Watch "SQL ResultSet error" New topic

SQL ResultSet error

madhu cm

Joined: Jun 26, 2005
Posts: 22
i need to sum all the values in the column called price which is in DataBase, but when i use :
<% Statement s = con.createStatement();
ResultSet rs = s.executeQuery("select SUM(after_discount) from details"); %>

<%= rs %>

i am getting msg as "sun.jdbc.odbc.JdbcOdbcResultSet@1d95da8" .... i dont know why....

as s.executeQuery() returns ResultSet... so i am using ResultSet rs....
can you plz tell me is any other way to get the output which sum the column???
[ July 31, 2005: Message edited by: Bear Bibeault ]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
rs is an object, not a value. Take a look at its javadocs to learn what methods it has that you can use to get at the actual data it returns. Most likely you want "rs.getDouble(1)".

Edited: ... after you have done "" of course.
[ July 31, 2005: Message edited by: Ulf Dittmer ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

"madhu cm",

There aren't may rules that have been put into place here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

Moved to the JDBC forum.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Here is the doc.
I agree. Here's the link:
subject: SQL ResultSet error
It's not a secret anymore!