예제 #1
0
  public void insertTour(Tour tour) throws Exception {
    try {
      Statement statement = connection.createStatement();
      statement.executeUpdate(
          String.format(
              "INSERT INTO tour (location_id, start_date, count_days, price) "
                  + "VALUES(%s, '%s', %s, %s)",
              tour.getLocationId(),
              tour.getStartDate().toString(),
              tour.getCountDays(),
              tour.getPrice()));

    } finally {
      closeConnention();
    }
  }
예제 #2
0
  public void updateTour(Tour tour, String id) throws SQLException {
    try {
      Statement statement = connection.createStatement();
      statement.executeUpdate(
          String.format(
              "UPDATE tour SET location_id=%s AND start_date='%s' "
                  + "AND count_days=%s AND price=%s WHERE id=%s",
              tour.getLocationId(),
              tour.getStartDate().toString(),
              tour.getCountDays(),
              tour.getPrice(),
              id));

    } finally {
      closeConnention();
    }
  }