I have a working Dao manager/SqlMap implementaion for a portal.

How would I change the configuration or implementation so that I can use a diferent dao.xml file at night than during the day without compromising connection pooling etc.

Originaly my dao config looed like this

public class DaoConfig {

        private static final DaoManager daoManager;

        static {

                try {
                        String resource = "com/uop/struts/dao/dao.xml";
                        Reader reader = Resources.getResourceAsReader(resource);
                        daoManager = DaoManagerBuilder.buildDaoManager(reader);
                } catch (Exception e) {
                        throw new RuntimeException(
                                        "Could not initialize DaoConfig.  Cause: 
" + e);
                }
        }

        public static DaoManager getDaomanager() {
                return daoManager;
        }
}

I then changed it to this :-

public class DaoConfig {

private static DaoManager daoManager;

public static DaoManager getDaomanager() {
try {
String resource = null;
Calendar date = new GregorianCalendar();
if (date.get(Calendar.HOUR_OF_DAY) > 8 && (date.get(Calendar.HOUR_OF_DAY) < 20) {
resource = "com/uop/struts/dao/daoDay.xml";
} else {
resource = "com/uop/struts/dao/daoNight.xml";
}
Reader reader = Resources.getResourceAsReader(resource);
daoManager = DaoManagerBuilder.buildDaoManager(reader);


                } catch (Exception e) {
                throw new RuntimeException(
                                "Could not initialize DaoConfig.  Cause: " + e);
        }
        return daoManager;
}

However each time I call
DaoConfig.getDaomanager() it looks as though it creates a new DaoManager rather than returning the existing one for the current period.


does this make sense?
any help greatfully received
thanks

--
Mark Ferguson

Reply via email to