package com.eactive.eai.batch.eventscheduler.holiday;

import com.eactive.eai.common.dao.BaseDAO;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;

import java.sql.ResultSet;
import java.util.ArrayList;

public class HolidayDAO extends BaseDAO implements HolidayQuery
{

    public HolidayDAO()
    {
    }

    public ArrayList<HolidayVO> getAllHolidays() throws DAOException
    {

        ArrayList<HolidayVO> holidays = new ArrayList<HolidayVO>();
        try
        {
            connect(GET_ALL_HOLIDAY);
            ResultSet rs = executeQuery();

            while(rs.next()) {
            	HolidayVO vo = new HolidayVO(rs.getString(1).trim(), rs.getString(2).trim(), rs.getString(3).trim());
                holidays.add(vo);
            }
            return holidays;

        }catch(Exception e){
            throw new DAOException(ExceptionUtil.getErrorCode(e, "BECEAIMEH001"));
        }
        finally
        {
            disconnect();
        }
    }
}
