catch (Exception e) { try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (Exception ignore) { } throw new RemoteException("Exception getting buyNow: " + e +"<br>"); }
sellerStmt.setInt(1, sellerId); sellerResult = sellerStmt.executeQuery();  if (sellerResult.first()) sellerName = sellerResult.getString("nickname");
  public String listBoughtItems(Integer userId, Connection conn) throws RemoteException   {    ResultSet buy = null;    PreparedStatement stmt = null;    String itemName = null, sellerName = null;    int quantity=0, sellerId=-1, itemId=-1;    float buyNow=0;    StringBuffer html = new StringBuffer();    // Get the list of items the user bought    try     {      stmt = conn.prepareStatement("SELECT * FROM buy_now WHERE buy_now.buyer_id=? AND TO_DAYS(NOW()) - TO_DAYS(buy_now.date)<=30");      stmt.setInt(1, userId.intValue());      buy = stmt.executeQuery();      if (!buy.first())      {        return printHTMLHighlighted("<br><h3>You didn't buy 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 bought items list: " +e+"<br>");    }    html.append(printUserBoughtItemHeader());    try    {      do      {	itemId = buy.getInt("item_id");	quantity = buy.getInt("qty");        // Get the name of the items        try        {	  try	  {            ResultSet itemRS = null;            PreparedStatement itemStmt = conn.prepareStatement("SELECT * FROM items WHERE id=?");            itemStmt.setInt(1, itemId);            itemRS = itemStmt.executeQuery();            if (itemRS.first())            {              itemName = itemRS.getString("name");              sellerId = itemRS.getInt("seller");              buyNow = itemRS.getFloat("buy_now");            }	  }	  catch (SQLException e)          {            try            {              if (stmt != null) stmt.close();              if (conn != null) conn.close();            }            catch (Exception ignore)            {            }            throw new RemoteException("Failed to execute Query for item (buy now): " +e);          }	  try           {            PreparedStatement 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 (stmt != null) stmt.close();              if (conn != null) conn.close();            }            catch (Exception ignore)            {            }            throw new RemoteException("Failed to execute Query for seller (buy now): " +e);          }        }        catch (Exception e)         {          try          {            if (stmt != null) stmt.close();            if (conn != null) conn.close();          }          catch (Exception ignore)          {          }          throw new RemoteException("Exception getting buyNow: " + e +"<br>");        }        // display information about the item        html.append(printUserBoughtItem(itemId, itemName, quantity, buyNow, sellerId, sellerName));      }      while(buy.next());    }    catch (Exception e)    {      throw new RemoteException("Exception getting bought items: " +e+"<br>");    }    html.append(printItemFooter());    return html.toString();  }