if (itemStmt != null) itemStmt.close(); if (sellerStmt != null) sellerStmt.close();
stmt.close(); itemStmt.close(); sellerStmt.close();
  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();      stmt.close();      if (!bid.first())      {        return printHTMLHighlighted("<h3>You didn't put any bid.</h3>");      }    }    catch (Exception e)    {      try { stmt.close(); } catch (Exception ignore) {}      try { conn.close(); } catch (Exception ignore) {}      throw new RemoteException("Exception getting bids list: " +e+"<br>");    }    html = new StringBuffer(printUserBidsHeader());    PreparedStatement itemStmt = null;    PreparedStatement sellerStmt = null;    try    {      itemStmt = conn.prepareStatement("SELECT * FROM items WHERE id=?");      sellerStmt = conn.prepareStatement("SELECT nickname FROM users WHERE id=?");      ResultSet rs = null;      ResultSet sellerResult = null;      do       {	itemId = bid.getInt("item_id");	maxBid = bid.getFloat("max_bid");        itemStmt.setInt(1, itemId);        rs = itemStmt.executeQuery();        // Get the name of the items        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;        }        sellerStmt.setInt(1, sellerId);        sellerResult = sellerStmt.executeQuery();        // Get the seller's name		         if (sellerResult.first())           sellerName = sellerResult.getString("nickname");        //  display information about user's bids        html.append(printItemUserHasBidOn(itemId, itemName, initialPrice,maxBid, currentPrice, quantity, startDate, endDate, sellerId, sellerName, username, password));      }      while(bid.next());      if (itemStmt != null) itemStmt.close();      if (sellerStmt != null) sellerStmt.close();    }    catch (Exception e)     {      try { itemStmt.close(); } catch (Exception ignore) {}      try { sellerStmt.close(); } catch (Exception ignore) {}      try { conn.close(); } catch (Exception ignore) {}      throw new RemoteException("Exception getting items the user has bid on: " + e +"<br>");    }    html.append(printItemFooter());    return html.toString();  }