Exemplo n.º 1
0
  public String execute() throws Exception {
    DatabaseUtils db = new DatabaseUtils();
    Connection connection = db.getConnectionDb();
    HttpSession session = ServletActionContext.getRequest().getSession();

    PreparedStatement statement =
        connection.prepareStatement(
            "select CM.BALANCE,SM.AVAILABLE_SHARE from COMPANY_MASTER CM, COMPANY_SHARE_MASTER SM   where CM.MEMBERSHIP_ID=SM.MEMBERSHIP_ID AND  CM.MEMBERSHIP_ID= ?");
    statement.setString(1, (String) session.getAttribute("memberId"));
    ResultSet set = statement.executeQuery();
    if (set.next()) {
      setBalance(set.getDouble(1));
      setAvailableShare(set.getInt(2));
      return SUCCESS;
    } else return ERROR;
  }
  public String execute() throws Exception {
    DatabaseUtils db = new DatabaseUtils();
    Connection connection = db.getConnectionDb();
    HttpSession session = ServletActionContext.getRequest().getSession();
    String userName = (String) session.getAttribute("name");
    String memberIdOfUser = (String) session.getAttribute("memberId");
    PreparedStatement ps =
        connection.prepareStatement("insert into MESSAGE_TO_COMPANY values( ?,?,?,?,?,?)");

    ps.setString(1, memberIdOfUser);
    ps.setString(2, memberShipId);
    ps.setString(3, userName);
    ps.setString(4, customerMessageToCompany);
    ps.setBoolean(5, false); // isread by company
    ps.setTimestamp(6, new Timestamp(System.currentTimeMillis()));

    int b = ps.executeUpdate();
    if (b == 1) return SUCCESS;
    else return ERROR;
  }