예제 #1
0
 public static Plan selectPlan(int planID) throws TextFormatException, SQLException {
   DBUtil du = DBUtil.getDBUtil();
   String SQLCommand = null;
   ResultSet rs;
   if (planID < 0) throw new TextFormatException("userID is null");
   SQLCommand = " select * from " + tableName + " where planID = " + planID;
   rs = du.executeQuery(SQLCommand);
   rs.next();
   return new Plan(
       rs.getInt("planID"),
       rs.getString("title"),
       rs.getString("siteIDs"),
       rs.getDate("startTime"),
       rs.getDate("endTime"),
       rs.getInt("organizer"),
       rs.getString("participants"),
       rs.getInt("budget"),
       rs.getInt("groupNum"),
       rs.getInt("groupNumMax"),
       rs.getInt("talkStreamID"),
       rs.getBoolean("isDone"),
       rs.getTimestamp("timestamp"),
       rs.getString("information"));
 }
예제 #2
0
  public static Vector<Plan> selectPlan(Plan plan) throws TextFormatException, SQLException {
    assert plan.getTitle().length() < 80;
    DBUtil du = DBUtil.getDBUtil();
    String SQLCommand = null;
    ResultSet rs;
    Plan result_plan;
    boolean isAnd = false;
    if (plan == null) throw new TextFormatException();
    String siteIDs = plan.getSiteIDs();
    Date startTime = plan.getStartTime();
    Date endTime = plan.getEndTime();
    int organizer = plan.getOrganizer();
    String participants = plan.getParticipants();
    int budget = plan.getBudget();
    int groupNum = plan.getGroupNum();
    int groupNumMax = plan.getGroupNumMax();
    int talkStreamID = plan.getTalkStreamID();
    SQLCommand = " select * from " + tableName + " where ";
    if (budget >= 0) {
      SQLCommand += " budget = '" + budget + "'";
      isAnd = true;
    }
    if (groupNum >= 0) {
      if (isAnd) SQLCommand += " and ";
      SQLCommand += " groupNum = " + groupNum;
      isAnd = true;
    }
    if (groupNumMax >= 0) {
      if (isAnd) SQLCommand += " and ";
      SQLCommand += " groupNumMax = " + groupNumMax;
      isAnd = true;
    }
    if (talkStreamID >= 0) {
      if (isAnd) SQLCommand += " and ";
      SQLCommand += " talkStreamID = " + talkStreamID;
      isAnd = true;
    }
    if (organizer >= 0) {
      if (isAnd) SQLCommand += " and ";
      SQLCommand += " organizer = " + organizer;
      isAnd = true;
    }
    if (startTime != null) {
      if (isAnd) SQLCommand += " and ";
      SQLCommand += " startTime >= '" + startTime + "'";
      isAnd = true;
    }
    if (endTime != null) {
      if (isAnd) SQLCommand += " and ";
      SQLCommand += " endTime <= '" + endTime + "'";
      isAnd = true;
    }
    rs = du.executeQuery(SQLCommand);
    Vector<Plan> vector = new Vector<Plan>();
    while (rs.next()) {
      result_plan =
          new Plan(
              rs.getInt("planID"),
              rs.getString("title"),
              rs.getString("siteIDs"),
              rs.getDate("startTime"),
              rs.getDate("endTime"),
              rs.getInt("organizer"),
              rs.getString("participants"),
              rs.getInt("budget"),
              rs.getInt("groupNum"),
              rs.getInt("groupNumMax"),
              rs.getInt("talkStreamID"),
              rs.getBoolean("isDOne"),
              rs.getTimestamp("timestamp"),
              rs.getString("information"));
      vector.add(result_plan);
    }

    return vector;
  }