if (itemStmt != null) itemStmt.close(); if (sellerStmt != null) sellerStmt.close();
stmt.close(); itemStmt.close(); sellerStmt.close();
  public String listWonItems(Integer userId, Connection conn) throws RemoteException   {    int sellerId=-1, itemId=-1;      float currentPrice=0, initialPrice=0;    String itemName = null, sellerName = null;    ResultSet won = null;    PreparedStatement stmt = null;    StringBuffer html;    // Get the list of the user's won items    try     {      stmt = conn.prepareStatement("SELECT item_id FROM bids, old_items WHERE bids.user_id=? AND bids.item_id=old_items.id AND TO_DAYS(NOW()) - TO_DAYS(old_items.end_date) < 30 GROUP BY item_id");      stmt.setInt(1, userId.intValue());      won = stmt.executeQuery();      stmt.close();      if (!won.first())      {        return printHTMLHighlighted("<br><h3>You didn't win any item in the last 30 days.</h3><br>");      }    }    catch (Exception e)    {      try { stmt.close(); } catch (Exception ignore) {}      try { conn.close(); } catch (Exception ignore) {}      throw new RemoteException("Exception getting won items list: " +e+"<br>");    }    html = new StringBuffer(printUserWonItemHeader());    PreparedStatement itemStmt = null;    PreparedStatement sellerStmt = null;    try    {      itemStmt = conn.prepareStatement("SELECT * FROM old_items WHERE id=?");      sellerStmt = conn.prepareStatement("SELECT nickname FROM users WHERE id=?");      ResultSet itemRS = null;      ResultSet sellerResult = null;      do       {	itemId = won.getInt("item_id");        // Get the name of the items        itemStmt.setInt(1, itemId);        itemRS = itemStmt.executeQuery();        if (itemRS.first())        {          itemName = itemRS.getString("name");          sellerId = itemRS.getInt("seller");          initialPrice = itemRS.getFloat("initial_price");          currentPrice = itemRS.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 the item        html.append(printUserWonItem(itemId, itemName, currentPrice, sellerId, sellerName));      }      while (won.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 won items: " +e+"<br>");    }    html.append(printItemFooter());    return html.toString();  }