⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbconnectorfactory.java

📁 j2ee源码
💻 JAVA
字号:
/*
 * Created on Oct 23, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.leeman.common.db;

import java.sql.SQLException;
import javax.naming.*;

import com.leeman.common.resource.*;

/**
 * @author dennis
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class DBConnectorFactory {
	
	public static final String ORACLE_CONNECTOR = "OracleConnector";
	public static final String WEBSPHERE_CONNECTOR = "WebsphereConnector";
	public static final String CUSTOM_ORACLE_CONNECTOR = "CustomOracleConnector";
	
	/**
	 * Get the Connector with Database Connection
	 * @param sDBType - Database Type "OracleConnector" or "WebsphereConnector"
	 * @return AbstractDBConnector containing the Database Connection
	 * @throws SQLException
	 * @throws NamingException
	 */
	public AbstractDBConnector getConnector(String sDBType) throws Exception
	{
		if (sDBType.equalsIgnoreCase(ORACLE_CONNECTOR))
		{
			return (AbstractDBConnector)new OracleConnector();
		}
		else if (sDBType.equalsIgnoreCase(WEBSPHERE_CONNECTOR))
		{
			return (AbstractDBConnector)new WebsphereConnector();
		}
		else
		{
			throw new Exception("Database Connector type not defined.");
		}
	}
	
	public AbstractDBConnector getConnector(String sDBType, String db_address, String db_user, String db_password) throws Exception
	{
		if (sDBType.equalsIgnoreCase(CUSTOM_ORACLE_CONNECTOR))
		{
			return (AbstractDBConnector)new OracleConnector(db_address, db_user, db_password);
		}
		else if (sDBType.equalsIgnoreCase(ORACLE_CONNECTOR))
		{
			return getConnector(sDBType);
		}
		else if (sDBType.equalsIgnoreCase(WEBSPHERE_CONNECTOR))
		{
			return getConnector(sDBType);
		}
		else
		{
			throw new Exception("Database Connector type not defined.");
		}
	}	
	public AbstractDBConnector getConnector() throws Exception{
		return getConnector(ConfigManager.getConfig("DB_TYPE"));
	}
	
}

⌨️ 快捷键说明

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