datasrcutil.java.svn-base

来自「一个timesheet程序,用来统计开发人员的度量衡web在线程序.用于软件行业」· SVN-BASE 代码 · 共 66 行

SVN-BASE
66
字号
package com.nsi.persistence;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.nsi.control.exceptions.NsiEventException;
import com.nsi.util.settings.SystemSettings;


public final class DataSrcUtil
{
	private static Log log = LogFactory.getLog(DataSrcUtil.class);
	/**
	 * private constructor of DataSrcUtil, prevent instantiation
	 */
	private DataSrcUtil()
	{
	}
	private static class DataSrcUtilHolder
	{
		static final DataSrcUtil dataSrcUtil = new DataSrcUtil();
	}
	/**
	 * @return an instance of DataSrcUtil
	 */
	public static DataSrcUtil getInstance()
	{
		return DataSrcUtilHolder.dataSrcUtil;
	}
	public IsqlDataSource getDataSource() throws NsiEventException
	{
		String datasourceclassname = SystemSettings.getInstance().getDBDataSourceClassName();
		IsqlDataSource drc = null;
		try
		{
			drc = (IsqlDataSource)getClass().getClassLoader().loadClass( datasourceclassname ).newInstance();
		}
		catch (ClassNotFoundException cnfex)
		{
			log.error("getDataSource() -- caught ClassNotFoundException: ", cnfex);
			throw new NsiEventException( "getDataSource() -- caught ClassNotFoundException: ", cnfex );
		}
		catch( InstantiationException initex)
		{
			log.error("getDataSource() -- caught InstantiationException: ", initex);
			throw new NsiEventException( "getDataSource() -- caught InstantiationException: ", initex );
		}
		catch( IllegalAccessException illegex)
		{
			log.error("getDataSource() -- caught IllegalAccessException: ", illegex);
			throw new NsiEventException( "getDataSource() -- caught IllegalAccessException: ", illegex );
		}
		catch( Exception ex)
		{
			log.error("getDataSource() -- caught Exception: ", ex);
			throw new NsiEventException( "getDataSource() -- caught Exception: ", ex );
		}
		catch( Throwable trex)
		{
			log.error("getDataSource() -- caught Throwable: ", trex);
			throw new NsiEventException( "getDataSource() -- caught Throwable: ", trex );
		}
		return drc;
	}
}

⌨️ 快捷键说明

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