File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes select MAX query Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "select MAX query" Watch "select MAX query" New topic
Author

select MAX query

hel bel
Greenhorn

Joined: Mar 05, 2003
Posts: 3
Could somebody pleeeeease tell me whats wrong with the following shopping cart code! I'm using a sybase database to hold order information and I'm trying to get the last order id from the order table using a select(MAX) query.
CODE:
/****************************************
PreparedStatement Stmt = connection.prepareStatement(query);
int order_idd = 0;
ResultSet resultset= Stmt.executeQuery("SELECT MAX(order_id) from orders");
while(resultset.next())
{
order_idd = resultset.getInt(2);
}
while(products.hasMoreElements())
{
Product product = (Product)products.nextElement();
Stmt = connection.prepareStatement(order_info_query);

Stmt.setInt(1, order_idd);
Stmt.executeUpdate();
}
Any help would be greatly appreciated!
Thanks!
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
looks like you are trying to get hold of the 2nd column but the query will only give you one column?
 
 
subject: select MAX query
 
Threads others viewed
Using a prepared statement
preparedStatement
What is wrong?
encrypted username breaks sql
thank you Jamie Robertson &Lewis Chao my code is:
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture