• Post Reply Bookmark Topic Watch Topic
  • New Topic

select MAX query  RSS feed

 
hel bel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 925
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
looks like you are trying to get hold of the 2nd column but the query will only give you one column?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!