Example #1
0
  public List<Utente> getAll() {
    logger.info("UtenteService::getAll()");

    List<Utente> utenti = null;
    Connection conn = null;

    try {

      conn = MyJNDIConnection.getConnection();
      UtenteDAO dao = new UtenteDAO();
      utenti = dao.findAll(conn);

    } catch (Exception e) {
      logger.error("errore inaspettato: " + e);
      throw new BusinessException(e.getMessage());
    } finally {
      try {
        conn.close();
      } catch (SQLException e) {
        logger.error("impossibile chiudere la connessione: " + e);
        throw new BusinessException(e.getMessage());
      }
    }

    return utenti;
  }
Example #2
0
  public Utente get(String k) {
    logger.info("UtenteService::get(k)");

    Utente utente = null;
    Connection conn = null;

    try {

      conn = MyJNDIConnection.getConnection();
      UtenteDAO dao = new UtenteDAO();
      utente = dao.findById(k, conn);

    } catch (Exception e) {
      logger.error("errore inaspettato: " + e);
      throw new BusinessException(e.getMessage());
    } finally {
      try {
        conn.close();
      } catch (SQLException e) {
        logger.error("impossibile chiudere la connessione: " + e);
        throw new BusinessException(e.getMessage());
      }
    }

    return utente;
  }