Пример #1
0
  public static void populateContext(final HttpSession session, final PageContext page) {

    final DataSource importDataSource =
        SessionAttributes.getNonNullAttribute(session, "dbimport", DataSource.class);

    Connection connection = null;
    try {
      connection = importDataSource.getConnection();

      final List<Tournament> tournaments = Tournament.getTournaments(connection);
      page.setAttribute("tournaments", tournaments);

    } catch (final SQLException e) {
      LOGGER.error("There was an error talking to the database", e);
      throw new RuntimeException("There was an error talking to the database", e);
    } finally {
      SQLFunctions.close(connection);
    }
  }