aspose file tools*
The moose likes JDBC and the fly likes SQL ResultSet error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL ResultSet error" Watch "SQL ResultSet error" New topic
Author

SQL ResultSet error

madhu cm
Greenhorn

Joined: Jun 26, 2005
Posts: 22
hello
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
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
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 "rs.next()" of course.
[ July 31, 2005: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61424
    
  67

"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.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61424
    
  67

Moved to the JDBC forum.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Here is the doc.
 
 
subject: SQL ResultSet error