📄 datasrcutil.java.svn-base
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -