PreparedStatement pstmt = null;
  public String getComments(Integer userId, Connection conn) throws RemoteException  {    StringBuffer html;    PreparedStatement stmt = null;    ResultSet rs           = null;    String comment=null, date=null;    int authorId;    // Try to find the comments corresponding for this user    try    {      stmt = conn.prepareStatement("SELECT * FROM comments WHERE to_user_id=?");      stmt.setInt(1, userId.intValue());      rs = stmt.executeQuery();      stmt.close();    }    catch (SQLException e)    {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Failed to get the comments " +e);    }    try     {      if (!rs.first())       html = new StringBuffer("<h3>There is no comment yet for this user.</h3><br>");      else      {        html = new StringBuffer("<br><hr><br><h3>Comments for this user</h3><br>");        html.append(printCommentHeader());        // Display each comment and the name of its author                try        {          stmt = conn.prepareStatement("SELECT nickname FROM users WHERE id=?");          do          {            comment = rs.getString("comment");            date = rs.getString("date");            authorId = rs.getInt("from_user_id");            String authorName = "none";            ResultSet authorRS = null;            stmt.setInt(1, authorId);            authorRS = stmt.executeQuery();            if (authorRS.first())              authorName = authorRS.getString("nickname");            html.append(printComment(authorName, date, comment, authorId));          }          while (rs.next());        }        catch (Exception e)        {          try          {            if (stmt != null) stmt.close();            if (conn != null) conn.close();          }          catch (Exception ignore)          {          }          throw new RemoteException("This author does not exist (got exception: " +e+")<br>");        }                html.append(printCommentFooter());      }      if (stmt != null) stmt.close();    }     catch (Exception e)     {      try      {        if (stmt != null) stmt.close();        if (conn != null) conn.close();      }      catch (Exception ignore)      {      }      throw new RemoteException("Exception getting comment list: " + e +"<br>");    }    return html.toString();  }