daofactory.java

来自「一个用struts tiles的在线影院web系统」· Java 代码 · 共 44 行

JAVA
44
字号
package com.eline.vod.security.dao;

import com.blue.web.common.exceptions.DAOSysException;
import com.blue.web.common.util.AppSettings;
import com.eline.vod.utils.AppKeys;

public class DAOFactory {
	public static UserDAO getUserDAO() throws DAOSysException {
		UserDAO dao = null;
		System.out.println("hello from DAOFactory");
		try {
			String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
			System.out.println("provider=" + provider);
			if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
				dao = new MSSqlUserDAO();
			else if (provider.equalsIgnoreCase("Oracle"))
				throw new DAOSysException("unsupported datasource type."); 
		} catch (DAOSysException e) {
			e.printStackTrace();
			throw new DAOSysException("DAOFactory.getUserDAO:  DAOSysException while getting DAO type : \n" + e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
			throw new DAOSysException("DAOFactory.getUserDAO:  Exception while getting DAO type : \n" + e.getMessage());
		}
		System.out.println("dao=" + dao);
		return dao;
	}
	public static RoleDAO getRoleDAO() throws DAOSysException {
		RoleDAO dao = null;
		try {
			String provider = AppSettings.getInstance().getProperty(AppKeys.DS_TYPE);
			if (provider == null || provider.equals("") || provider.equalsIgnoreCase("SQLServer"))
				dao = new MSSqlRoleDAO();
			else if (provider.equalsIgnoreCase("Oracle"))
				throw new DAOSysException("unsupported datasource type."); 
		} catch (DAOSysException e) {
			throw new DAOSysException("DAOFactory.getRoleDAO:  DAOSysException while getting DAO type : \n" + e.getMessage());
		} catch (Exception e) {
			throw new DAOSysException("DAOFactory.getRoleDAO:  Exception while getting DAO type : \n" + e.getMessage());
		}
		return dao;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?