try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (Exception ignore) { }
try { conn.close(); } catch (Exception ignore) {}
  public String getAboutMe(String username, String password) throws RemoteException  {    UserTransaction utx    = null;    PreparedStatement stmt = null;    ResultSet rs           = null;    Connection conn        = null;    int          uid       = -1;    Integer      userId    = null;    StringBuffer html      = new StringBuffer();    // Authenticate the user    SB_AuthHome authHome = null;    SB_Auth auth = null;    try     {      authHome = (SB_AuthHome)PortableRemoteObject.narrow(initialContext.lookup("java:comp/env/ejb/SB_Auth"), SB_AuthHome.class);      auth = authHome.create();    }     catch (Exception e)    {      throw new RemoteException("Cannot lookup SB_Auth: " +e);    }    try     {      uid = auth.authenticate(username, password);    }     catch (Exception e)    {      throw new RemoteException("Authentication failed: " +e);    }    if (uid == -1)    {      return "You don't have an account on RUBiS!<br>You have to register first.<br>";    }    else       userId = new Integer(uid);    // Try to find the user corresponding to the userId    String firstname = null, lastname = null, nickname = null, email = null, date = null;    int rating = 0;    try    {      conn = dataSource.getConnection();      stmt = conn.prepareStatement("SELECT * FROM users WHERE id=?");      stmt.setInt(1, userId.intValue());      rs = stmt.executeQuery();    }    catch (Exception e)    {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Failed to execute Query for user: " +e);    }    try     {      if (rs.first())      {        firstname = rs.getString("firstname");        lastname = rs.getString("lastname");        nickname = rs.getString("nickname");        email = rs.getString("email");        date = rs.getString("creation_date");        rating = rs.getInt("rating");      }      html.append("<h2>Information about "+nickname+"<br></h2>");      html.append("Real life name : "+firstname+" "+lastname+"<br>");      html.append("Email address  : "+email+"<br>");      html.append("User since     : "+date+"<br>");      html.append("Current rating : <b>"+rating+"</b><br>");    }    catch (Exception e)    {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("This user does not exist (got exception: " +e+")<br>");    }    utx = sessionContext.getUserTransaction();    try     {      utx.begin();      html.append(listItem(userId, conn));      html.append(listBoughtItems(userId, conn));      html.append(listWonItems(userId, conn));      html.append(listBids(userId, username, password, conn));      html.append(listComments(userId, conn));      if (stmt != null) stmt.close();      if (conn != null) conn.close();      utx.commit();    }     catch (Exception e)    {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Cannot get information about items and bids: " +e+"<br>");    }    return html.toString();  }