try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (Exception ignore) { }
try { stmt.close(); } catch (Exception ignore) {} try { conn.close(); } catch (Exception ignore) {}
  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();      if (!won.first())      {        return printHTMLHighlighted("<br><h3>You didn't win any item in the last 30 days.</h3><br>");      }    }    catch (Exception e)    {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Exception getting won items list: " +e+"<br>");    }    html = new StringBuffer(printUserWonItemHeader());    try    {      do       {	itemId = won.getInt("item_id");        // Get the name of the items        try        {          PreparedStatement itemStmt = null;	  try	  {            ResultSet itemRS = null;            itemStmt = conn.prepareStatement("SELECT * FROM old_items WHERE id=?");            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;            }	  }	  catch (SQLException e)          {            try            {              if (itemStmt != null) stmt.close();              if (conn != null) conn.close();            }            catch (Exception ignore)            {            }            throw new RemoteException("Failed to execute Query for item (won items): " +e);          }	  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 (SQLException e)          {            try            {              if (sellerStmt != null) stmt.close();              if (conn != null) conn.close();            }            catch (Exception ignore)            {            }            throw new RemoteException("Failed to execute Query for seller (won items): " +e);          }        }        catch (Exception e)         {          try          {            if (conn != null) conn.close();          }          catch (Exception ignore)          {          }          throw new RemoteException("Exception getting item: " + e +"<br>");        }        // display information about the item        html.append(printUserWonItem(itemId, itemName, currentPrice, sellerId, sellerName));      }      while(won.next());    }    catch (Exception e)    {      try      {        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Exception getting won items: " +e+"<br>");    }    html.append(printItemFooter());    return html.toString();  }