This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes maximum value of a column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "maximum value of a column" Watch "maximum value of a column" New topic
Author

maximum value of a column

lakshmanan anand
Greenhorn

Joined: Jan 13, 2009
Posts: 22
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.


http://luckydev07.blogspot.com
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289


res.next();
you have to move the resultset to some specific location before doing get operation


-Chiru
 
GeeCON Prague 2014
 
subject: maximum value of a column