Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

maximum value of a column

 
lakshmanan anand
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am trying to add rows to a table (name : csv) whose schema is

ID Name Place
-- ------ --------

ResultSet res = stmt.executeQuery("select max(id) as id from csv");
int i = res.getInt("id");
i++;

i want to get the maximum value of ID . when i typed the above code, i get SQLException. what shall i do.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

res.next();
you have to move the resultset to some specific location before doing get operation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic