daofactory.java

来自「用xml+swing+jdbc(hsqldb)写的电视广告管理软件 客户定义好」· Java 代码 · 共 37 行

JAVA
37
字号
package dao;

public class DaoFactory {
	// create other DAO instances

	
	public static PlageDao getPlageDao() throws DAOException{
		return (PlageDao) createDAO(PlageDao.class);
	}
	
	public static ContratDao getContratDao() throws DAOException{
		return (ContratDao) createDAO(ContratDao.class);
	}
	public static SpotDao getSpotDao() throws DAOException{
		return (SpotDao) createDAO(SpotDao.class);
	}

	// method to create a DAO instance. Can be optimized to
	// cache the DAO Class instead of creating it everytime.
	private static Object createDAO(Class classObj) throws DAOException {
		Object o = null;
		try {
			o = classObj.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return o;
	}

	public static CategorieDao getCategorieDao() throws DAOException {
		return (CategorieDao) createDAO(CategorieDao.class);
	}

}

⌨️ 快捷键说明

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