Esempio n. 1
0
  public OfferUser getOfferUser(int offerId, int userId) throws InvocationTargetException {
    String sql =
        "select offer_id as offerId, USER_ID as userId,status from offer_user "
            + " where offer_id = ? and USER_ID= ?";
    OfferUser offerUser = null;
    try {
      this.pstmt = JDBCDataConnection.getConnection().prepareStatement(sql);
      this.pstmt.setInt(1, offerId);
      this.pstmt.setInt(2, userId);
      ResultSet rs = this.pstmt.executeQuery();

      Object[] obj =
          ResultSetToModel.parseDataEntityBeans(rs, "com.offerme.server.database.model.OfferUser");
      if (obj.length > 0) {
        offerUser = (OfferUser) obj[0];
      }

    } catch (Exception e) {

      String err = Log.getStackInfo(e);
      myLog.error(err);
      throw new InvocationTargetException(e, err);
    } finally {
      this.free();
    }

    return offerUser;
  }
Esempio n. 2
0
  public List<Integer> getOfferListIdByUserId(int userId) throws InvocationTargetException {
    List<Integer> offerIdList = new ArrayList<Integer>();
    String sql = "select offer_id as offerId from offer_user " + " where USER_ID = ? ";
    try {
      this.pstmt = JDBCDataConnection.getConnection().prepareStatement(sql);
      this.pstmt.setInt(1, userId);
      ResultSet rs = this.pstmt.executeQuery();
      List<Object> obj = ResultSetToModel.parseDataEntityBeanList(rs, "java.lang.Integer");
      Integer offerId = null;
      for (Object object : obj) {
        offerId = (Integer) object;
        offerIdList.add(offerId);
      }
    } catch (Exception e) {

      String err = Log.getStackInfo(e);
      myLog.error(err);
      throw new InvocationTargetException(e, err);
    } finally {
      this.free();
    }
    return offerIdList;
  }