• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL ResultSet error

 
madhu cm
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the doc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic