Package com.alexnevsky.hotel.dao.exception

Examples of com.alexnevsky.hotel.dao.exception.DAOException


      resultSet = preparedStatement.executeQuery();
      if (resultSet.next()) {
        admin = mapAdmin(resultSet);
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, resultSet);
    }

    return admin;
View Full Code Here


      resultSet = preparedStatement.executeQuery();
      while (resultSet.next()) {
        users.add(mapAdmin(resultSet));
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, resultSet);
    }

    return users;
View Full Code Here

    try {
      connection = this.daoFactory.getConnection();
      preparedStatement = prepareStatement(connection, SQL_INSERT, true, values);
      int affectedRows = preparedStatement.executeUpdate();
      if (affectedRows == 0) {
        throw new DAOException("Creating Admin failed, no rows affected.");
      }
      generatedKeys = preparedStatement.getGeneratedKeys();
      if (generatedKeys.next()) {
        admin.setId(generatedKeys.getLong(1));
      } else {
        throw new DAOException("Creating Admin failed, no generated key obtained.");
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, generatedKeys);
    }
  }
View Full Code Here

    try {
      connection = this.daoFactory.getConnection();
      preparedStatement = prepareStatement(connection, SQL_UPDATE, false, values);
      int affectedRows = preparedStatement.executeUpdate();
      if (affectedRows == 0) {
        throw new DAOException("Updating Admin failed, no rows affected.");
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement);
    }
  }
View Full Code Here

    try {
      connection = this.daoFactory.getConnection();
      preparedStatement = prepareStatement(connection, SQL_DELETE, false, values);
      int affectedRows = preparedStatement.executeUpdate();
      if (affectedRows == 0) {
        throw new DAOException("Deleting admin failed, no rows affected.");
      } else {
        admin.setId(null);
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement);
    }
  }
View Full Code Here

      connection = this.daoFactory.getConnection();
      preparedStatement = prepareStatement(connection, sql, false, values);
      resultSet = preparedStatement.executeQuery();
      exist = resultSet.next();
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, resultSet);
    }

    return exist;
View Full Code Here

      resultSet = preparedStatement.executeQuery();
      if (resultSet.next()) {
        customerAccount = mapCustomerAccount(resultSet);
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, resultSet);
    }

    return customerAccount;
View Full Code Here

      resultSet = preparedStatement.executeQuery();
      while (resultSet.next()) {
        users.add(mapCustomerAccount(resultSet));
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, resultSet);
    }

    return users;
View Full Code Here

    try {
      connection = this.daoFactory.getConnection();
      preparedStatement = prepareStatement(connection, SQL_INSERT, true, values);
      int affectedRows = preparedStatement.executeUpdate();
      if (affectedRows == 0) {
        throw new DAOException("Creating CustomerAccount failed, no rows affected.");
      }
      generatedKeys = preparedStatement.getGeneratedKeys();
      if (generatedKeys.next()) {
        customerAccount.setId(generatedKeys.getLong(1));
      } else {
        throw new DAOException("Creating CustomerAccount failed, no generated key obtained.");
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement, generatedKeys);
    }
  }
View Full Code Here

    try {
      connection = this.daoFactory.getConnection();
      preparedStatement = prepareStatement(connection, SQL_UPDATE, false, values);
      int affectedRows = preparedStatement.executeUpdate();
      if (affectedRows == 0) {
        throw new DAOException("Updating CustomerAccount failed, no rows affected.");
      }
    } catch (SQLException e) {
      throw new DAOException(e);
    } finally {
      close(connection, preparedStatement);
    }
  }
View Full Code Here

TOP

Related Classes of com.alexnevsky.hotel.dao.exception.DAOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.