daofactory.java

来自「基于RCP实现的CRM系统, 数据库使用mysql数据库, 是学习RCP应用和插」· Java 代码 · 共 54 行

JAVA
54
字号
package superCRM.dao;

public class DaoFactory {

	/** 定义数据库类型的常量 */
	public static final String MYSQL = "mysql";

	public static final String ORACLE = "oracle";

	public static final String SQLSERVER = "sql_server";

	/** 数据库的类型 */
	private String dbType = MYSQL;

	private ICustomerDao customerDao;

	private IContactDao contactDao;

	/** 构造方法 */
	public DaoFactory() {
		/** 如果数据库类型为mysql */
		if (dbType.equals(MYSQL)) {
			customerDao = new CustomerDaoMysqlImpl();
			contactDao = new ContactDaoMysqlImpl();
		}
	}

	/** 一些getter和setter方法 */
	public IContactDao getContactDao() {
		return contactDao;
	}

	public void setContactDao(IContactDao contactDao) {
		this.contactDao = contactDao;
	}

	public ICustomerDao getCustomerDao() {
		return customerDao;
	}

	public void setCustomerDao(ICustomerDao customerDao) {
		this.customerDao = customerDao;
	}

	public String getDbType() {
		return dbType;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

}

⌨️ 快捷键说明

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