Пример #1
0
  public static Map<String, Table> mapTableReserver(DAOFactory daoFactory, long id)
      throws SQLException {
    String SQL_SELECT_PAR_ID =
        "SELECT * FROM reservation_tb,table_tb WHERE reservation_tb.idtable = table_tb.id AND reservation_tb.id = ?";
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;
    Map<String, Table> tables = null;
    tables = new HashMap<String, Table>();

    try {
      connection = daoFactory.getConnection();
      preparedStatement = initialisationRequetePreparee(connection, SQL_SELECT_PAR_ID, false, id);
      resultSet = preparedStatement.executeQuery();
      while (resultSet.next()) {
        Table table = new Table();

        table.setId(resultSet.getLong("idtable"));
        table.setNom(resultSet.getString("nom"));
        table.setNbrePlace(resultSet.getLong("nbreplace"));
        table.setNbrePlaceDipso(resultSet.getLong("nbreplacedispo"));

        tables.put(resultSet.getString("nom"), table);
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      fermeturesSilencieuses(resultSet, preparedStatement, connection);
    }

    return tables;
  }
Пример #2
0
  /*
   * Simple méthode utilitaire permettant de faire la correspondance(le
   * mapping) entre une ligne issue de la table des places assises du restaurant (un
   * ResultSet) et un bean Table.
   */
  public static Table mapTable(ResultSet resultSet) throws SQLException {
    Table table = new Table();

    table.setId(resultSet.getLong("id"));
    table.setNom(resultSet.getString("nom"));
    table.setNbrePlace(resultSet.getLong("nbreplace"));
    table.setNbrePlaceDipso(resultSet.getLong("nbrepacedispo"));

    return table;
  }