if (conn != null) conn.close();
  public void createComment(Integer fromId, Integer toId, Integer itemId, int rating, String comment) throws RemoteException  {    PreparedStatement stmt = null;    ResultSet rs           = null;    Connection conn        = null;    utx = sessionContext.getUserTransaction();    try    {      utx.begin();      try       {        // create new comment        String now = TimeManagement.currentDateToString();        conn = dataSource.getConnection();        stmt = conn.prepareStatement("INSERT INTO comments VALUES (NULL, \""+                                     fromId.intValue()+                                     "\", \""+toId.intValue()+"\", \""+itemId.intValue()+                                     "\", \""+ rating+"\", \""+now+"\",\""+comment+"\")");        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 comment (got exception: " +e+")<br>");      }      // Try to find the user corresponding to the 'to' ID      try      {        stmt = conn.prepareStatement("SELECT rating FROM users WHERE id=?");        stmt.setInt(1, toId.intValue());        rs = stmt.executeQuery();                if (rs.first())        {          int userRating = rs.getInt("rating");          userRating = userRating + rating;           stmt = conn.prepareStatement("UPDATE users SET rating=? WHERE id=?");          stmt.setInt(1, userRating);          stmt.setInt(2, toId.intValue());          stmt.executeUpdate();                  }        stmt.close();      }      catch (SQLException e)      {        try { stmt.close(); } catch (Exception ignore) {}        try { conn.close(); } catch (Exception ignore) {}        throw new RemoteException("Error while updating user's rating (got exception: " +e+")<br>");      }      if (conn != null) conn.close();      utx.commit();    }    catch (Exception e)    {      try { conn.close(); } catch (Exception ignore) {}      try      {        utx.rollback();        throw new RemoteException("Error while storing the comment (got exception: " +e+")<br>");      }      catch (Exception se)       {        throw new RemoteException("Transaction rollback failed: " + e +"<br>");      }    }  }