try { itemStmt = conn.prepareStatement("SELECT * FROM items WHERE id=?"); itemStmt.setInt(1, itemId); rs = itemStmt.executeQuery(); } catch (Exception e) { throw new RemoteException("Failed to execute Query for item the user has bid on: " +e); }
itemStmt.setInt(1, itemId); rs = itemStmt.executeQuery();
  public String listBids(Integer userId, String username, String password, Connection conn) throws RemoteException   {    float currentPrice = 0, initialPrice = 0, maxBid = 0;    String itemName = null, sellerName = null, startDate = null, endDate = null;    int sellerId = -1, quantity = 0, itemId = -1;    ResultSet bid = null;    PreparedStatement stmt = null;    StringBuffer html = null;    // Get the list of the user's last bids    try     {      stmt = conn.prepareStatement("SELECT item_id, bids.max_bid FROM bids, items WHERE bids.user_id=? AND bids.item_id=items.id AND items.end_date>=NOW() GROUP BY item_id");      stmt.setInt(1, userId.intValue());      bid = stmt.executeQuery();      if (!bid.first())      {        return printHTMLHighlighted("<h3>You didn't put any bid.</h3>");      }    }    catch (Exception e)    {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Exception getting bids list: " +e+"<br>");    }    html = new StringBuffer(printUserBidsHeader());    ResultSet rs = null;    PreparedStatement itemStmt = null;    try    {      do       {	itemId = bid.getInt("item_id");	maxBid = bid.getFloat("max_bid");	try	{             itemStmt = conn.prepareStatement("SELECT * FROM items WHERE id=?");          itemStmt.setInt(1, itemId);          rs = itemStmt.executeQuery();	}	catch (Exception e)	{          throw new RemoteException("Failed to execute Query for item the user has bid on: " +e);	}        // Get the name of the items        try        {	  if (rs.first()) 	  {            itemName = rs.getString("name");            initialPrice = rs.getFloat("initial_price");            quantity = rs.getInt("quantity");            startDate = rs.getString("start_date");            endDate = rs.getString("end_date");              sellerId = rs.getInt("seller");            currentPrice = rs.getFloat("max_bid");            if (currentPrice <initialPrice)              currentPrice = initialPrice;	  }	  PreparedStatement sellerStmt = null;	  try           {            sellerStmt = conn.prepareStatement("SELECT nickname FROM users WHERE id=?");            sellerStmt.setInt(1, sellerId);            ResultSet sellerResult = sellerStmt.executeQuery();            // Get the seller's name		             if (sellerResult.first())               sellerName = sellerResult.getString("nickname");          }	  catch (Exception e)          {            try            {              if (sellerStmt != null) stmt.close();              if (conn != null) conn.close();            }            catch (Exception ignore)            {            }            throw new RemoteException("Failed to execute Query for seller (bids): " +e);          }        }        catch (Exception e)         {          throw new RemoteException("Exception getting item: " + e +"<br>");        }        //  display information about user's bids        html.append(printItemUserHasBidOn(itemId, itemName, initialPrice,maxBid, currentPrice, quantity, startDate, endDate, sellerId, sellerName, username, password));      }      while(bid.next());    }    catch (Exception e)     {      throw new RemoteException("Exception getting items the user has bid on: " + e +"<br>");    }    html.append(printItemFooter());    return html.toString();  }