stmt.close();
  public void createBid(int userId, int itemId, float bid, float maxBid, int qty) throws RemoteException  {    PreparedStatement stmt = null;    ResultSet rs           = null;    Connection conn        = null;    utx = sessionContext.getUserTransaction();    try    {      utx.begin();      try       {        // create new bid        conn = dataSource.getConnection();        String now = TimeManagement.currentDateToString();        stmt = conn.prepareStatement("INSERT INTO bids VALUES (NULL, \""+userId+				   "\", \""+itemId+"\", \""+qty+"\", \""+				   bid+"\", \""+maxBid+"\", \""+now+"\")");        stmt.executeUpdate();        stmt.close();      }      catch (SQLException e)      {        try { stmt.close(); } catch (Exception ignore) {}        try { conn.close(); } catch (Exception ignore) {}        throw new RemoteException("Error while storing the bid (got exception: " +e+")<br>");      }      // update the number of bids and the max bid for the item      PreparedStatement update = null;      try      {        stmt = conn.prepareStatement("SELECT nb_of_bids, max_bid FROM items WHERE id=?");        stmt.setInt(1, itemId);        rs = stmt.executeQuery();        stmt.close();        if (rs.first())        {          int nbOfBids = rs.getInt("nb_of_bids");          nbOfBids++;          float oldMaxBid = rs.getFloat("max_bid");          if (bid > oldMaxBid)          {            oldMaxBid = bid;            update = conn.prepareStatement("UPDATE items SET max_bid=?,nb_of_bids=? WHERE id=?");            update.setFloat(1, oldMaxBid);            update.setInt(2, nbOfBids);            update.setInt(3, itemId);            update.executeUpdate();          }          else          {            update = conn.prepareStatement("UPDATE items SET nb_of_bids=? WHERE id=?");            update.setInt(1, nbOfBids);            update.setInt(2, itemId);            update.executeUpdate();          }          update.close();        }      }      catch (Exception ex)       {        try { update.close(); } catch (Exception ignore) {}        try { stmt.close(); } catch (Exception ignore) {}        try { conn.close(); } catch (Exception ignore) {}        throw new RemoteException("Failed to update nb of bids and max bid: " + ex);      }      if (conn != null) conn.close();      utx.commit();    }    catch (Exception e)    {      try { conn.close(); } catch (Exception ignore) {}      try      {        utx.rollback();        throw new RemoteException("Failed to create a new bid (got exception: " +e+")<br>");      }      catch (Exception se)       {        throw new RemoteException("Transaction rollback failed: " + e +"<br>");      }    }  }