FSP에서 동시에 다른 2개 이상의 DB를 설정하고 사용하는 예
WebContent/META-INF/context.xml
<Context reloadable="true">
<Resource name="DEV_DB" auth="Container"
type="javax.sql.DataSource" driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://20.240.87.207:50009/costdb"
username="user01" password="userPwd" maxActive="20" maxIdle="10"
maxWait="-1" />
<Resource name="PMS_DEV" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@20.230.22.222:1521:hellopms"
username="user01" password="user01" maxActive="20" maxIdle="10"
maxWait="-1" />
</Context>
WEB-INF/fsp/conf/service.xml
<?xml version="1.0" encoding="euc-kr"?>
<server>
<!-- 디폴트 로거의 로그 출력 레벨을 설정한다 디폴트는 콘솔에 출력된다. -->
<default-log>
<debug output="false"/>
<information output="false"/>
<warning output="false"/>
<error output="false"/>
<fatal output="false"/>
</default-log>
<!-- LOG에 IN/OUT 정보 표시 여부 -->
<server-property name="INOUT_DEBUG">true</server-property>
<log>DebugLogService</log>
<manager>
<service name="DebugLogCategoryService"
code="com.sz.service.log.SimpleLogCategoryService">
<!--attribute name="CategoryName">com.sz.service.log.DEBUG_METHOD_CATEGORY</attribute-->
<attribute name="CategoryName">com.sz.service.log.SQL_INFO_CATEGORY</attribute>
<attribute name="PriorityRange">50:99</attribute>
<attribute name="RecordFactoryServiceName">#DebugLogRecordFactoryService</attribute>
<attribute name="RecordWriterServiceNames">
#ConsoleWriter
</attribute>
<depends>DebugLogRecordFactoryService</depends>
<depends>ConsoleWriter</depends>
<depends>FileWriter</depends>
</service>
<service name="DebugLogRecordFactoryService"
code="com.sz.service.writer.LogRecordFactoryService">
<attribute name="DateFormat">yyyy-MM-dd hh:mm:ss</attribute>
<attribute name="Format">[%DATE%] %MESSAGE% %LOG_REQ_ID% %LOG_TIME%</attribute>
</service>
<service name="ConsoleWriter"
code="com.sz.service.writer.ConsoleWriterService">
</service>
<service name="FileWriter"
code="com.sz.service.writer.OneWriteFileMessageWriterService">
<attribute name="File">logs/_</attribute>
<attribute name="OutputKey">false</attribute>
<!--attribute name="FilePrefix">%LOG_REQ_ID%</attribute-->
<!--attribute name="FilePrefix">LOG_REQ_ID</attribute-->
<attribute name="FilePostfix">%LOG_TIME%.log</attribute>
</service>
<service name="DebugLogService"
code="com.sz.service.log.ThreadManagedLogService">
<attribute name="CategoryServiceNames">
#DebugLogCategoryService
</attribute>
<attribute name="SystemDebugEnabled">false</attribute>
<attribute name="SystemErrorEnabled">true</attribute>
<attribute name="SystemFatalEnabled">true</attribute>
<attribute name="SystemInfoEnabled">false</attribute>
<attribute name="SystemWarnEnabled">false</attribute>
<attribute name="DebugEnabled">true</attribute>
<depends>DebugLogCategoryService</depends>
</service>
<!-- data source 용 jndi finder -->
<service name="DatasourceJndiFinder"
code="com.sz.service.jndi.DefaultJndiFinderService">
</service>
<!-- HttpFile 컴포넌트를 이용한 파일 업로드 서비스 -->
<service name="HttpFileManagerService"
code="com.sz.service.ui.miplatform.DefaultHttpFileManagerService">
<!-- 파일을 저장한 루트 디렉토리를 정의
WORK_DIR 속성으로부터 시작되는 상대경로 또는 절대경로로 지정 가능
-->
<attribute name="FileRootDir">D:/MICMS_TOOL/workspace/MICMS_WEB/WebContent/</attribute>
<!-- 서브 디렉토리를 key=실제디렉토리의 형태로 지정 -->
<attribute name="SubDirList">
board=sample/board
img=sample/images
download=sample/upload
upload=sample/upload
</attribute>
<!-- 요청한 디렉토리 키 정보가 SubDirList에 존재하지 않을 경우 디렉토리의
동적 생성을 지원할지 여부를 설정한다. 지원할 경우 true
-->
<attribute name="SupportDynamicDir">true</attribute>
<attribute name="SystemEncoding">euc-kr</attribute>
</service>
<!-- Connection 정보 설정 DB2 9.7에 접속하기 위한 설정 -->
<service name="DefaultConnectionFactory"
code="com.sz.service.resource.jdbc.JdbcConnectionFactoryDataSourceService">
<attribute name="DataSourceName">DEV_DB</attribute>
<attribute name="ManagedResource">false</attribute>
<attribute name="JndiFinderServiceName">#DatasourceJndiFinder</attribute>
<attribute name="JournalLevel">0</attribute>
<attribute name="SQLLogServiceName">#DebugLogService</attribute>
<attribute name="SupportGlobalTransaction">true</attribute>
<depends>DatasourceJndiFinder</depends>
<depends>DebugLogService</depends>
</service>
<!-- PMS DB정보(ORACLE 10g) -->
<service name="PmsConnectionFactory"
code="com.sz.service.resource.jdbc.JdbcConnectionFactoryDataSourceService">
<attribute name="DataSourceName">PMS_DEV</attribute>
<attribute name="ManagedResource">false</attribute>
<attribute name="JndiFinderServiceName">#DatasourceJndiFinder</attribute>
<attribute name="JournalLevel">0</attribute>
<attribute name="SQLLogServiceName">#DebugLogService</attribute>
<attribute name="SupportGlobalTransaction">true</attribute>
<depends>DatasourceJndiFinder</depends>
<depends>DebugLogService</depends>
</service>
<!-- SQL Factory 서비스로 SQL 그룹정보를 가지고 있는 config 파일 및
SQL 이 저장되어 있는 최상위 디렉토리를 설정한다. -->
<service name="SqlFactory"
code="com.sz.service.sqlmap.XMLFileSqlMapFactoryService">
<attribute name="ServiceConfigUrl">conf/sqlmap_config.xml</attribute>
<attribute name="SqlMapDirPath">sqlmap/</attribute>
<attribute name="FileCheckInterval">10000</attribute>
<attribute name="SqlMapFileCache">true</attribute>
</service>
<!--
Action Class를 동적으로 생성해 주는 Factory 서비스이다.
Services 항목에 서비스ID=실제구현 class 형태로 설정한다.
-->
<!-- 개발 -->
<service name="defaultAction"
code="com.sz.service.ui.miplatform.DefaultMiplatformAction">
<attribute name="SystemLoggerServiceName">#DebugLogService</attribute>
<attribute name="BizServiceName">defaultBiz</attribute>
<depends>DebugLogService</depends>
<!-- attribute name="OutputType">ZLIB</attribute-->
</service>
<service name="defaultBiz"
code="com.sz.service.ui.miplatform.MiplatformExecutableService">
<attribute name="JournalMode">false</attribute>
<attribute name="ResourceFactoryServiceName">#DefaultConnectionFactory</attribute>
<attribute name="SystemLoggerServiceName">#DebugLogService</attribute>
<depends>DebugLogService</depends>
<depends>DefaultConnectionFactory</depends>
</service>
<service name="pmsBiz"
code="com.sz.service.ui.miplatform.MiplatformExecutableService">
<attribute name="JournalMode">false</attribute>
<attribute name="ResourceFactoryServiceName">#PmsConnectionFactory</attribute>
<attribute name="SystemLoggerServiceName">#DebugLogService</attribute>
<depends>DebugLogService</depends>
<depends>PmsConnectionFactory</depends>
</service>
<!-- 퍼포먼스 처리용 데이터베이스 기록자 서비스 -->
<service name="PerformanceDbConnection"
code="com.sz.service.resource.jdbc.JdbcConnectionFactoryDataSourceService">
<attribute name="DataSourceName">DEV_DB</attribute>
<attribute name="JndiFinderServiceName">#DatasourceJndiFinder</attribute>
<depends>DatasourceJndiFinder</depends>
</service>
<!-- 데이터베이스에 퍼포먼스를 기록하는 서비스 -->
<service name="DBPerformanceManagerService"
code="com.sz.service.performance.DatabasePerformanceManagerService">
<attribute name="JdbcConnectionFactoryServiceName">#PerformanceDbConnection</attribute>
<depends>PerformanceDbConnection</depends>
</service>
<service name="SqlServerBiz"
code="com.sz.service.ui.miplatform.MiplatformExecutableService">
<attribute name="JournalMode">false</attribute>
<attribute name="ResourceFactoryServiceName">#SQLServerConnectionFactory</attribute>
<attribute name="SystemLoggerServiceName">#DebugLogService</attribute>
<depends>DebugLogService</depends>
<depends>SQLServerConnectionFactory</depends>
</service>
<service name="DatabaseExecutorService"
code="com.sz.console.DatabaseExecutorService">
</service>
<service name="MyAction"
code="kodt.temp.MyAction">
</service>
</manager>
<manager name="sql">
<service name="SqlMapLayoutService"
code="com.sz.service.sqlmap.layout.DefaultSqlMapLayoutService">
</service>
<service name="DefaultSqlMapManagerService"
code="com.sz.console.sqlmap.SqlMapManagerService">
<attribute name="ServiceConfigUrl">conf/sqlmap_config.xml</attribute>
<attribute name="SqlMapDirPath">sqlmap/</attribute>
</service>
<service name="DatabaseExecutorService"
code="com.sz.console.DatabaseExecutorService">
</service>
<!-- ORACLE -->
<service name="SqlMapManagerActionForOracle"
code="com.sz.console.sqlmap.SqlMapManagerAction">
<attribute name="SqlMapManagerServiceName">#DefaultSqlMapManagerService</attribute>
<attribute name="DBExecutorServiceName">#DatabaseExecutorService</attribute>
<depends>DefaultSqlMapManagerService</depends>
<depends>DatabaseExecutorService</depends>
</service>
<service name="SqlMapManagerAction"
code="com.sz.console.sqlmap.MultiSqlMapManagerAction">
<attribute name="JdbcConnectionServiceNames">
DEV_DB=DefaultConnectionFactory
,PMS_DEV=PmsConnectionFactory
</attribute>
<attribute name="SqlmapUser">mcams</attribute>
<attribute name="SqlmapPwd">mcams1</attribute>
<attribute name="SqlManagerActionNames">
sql#SqlMapManagerActionForOracle
,sql#SqlMapManagerActionForOracle
</attribute>
<attribute name="DatabaseLogin">
false
,false
</attribute>
<attribute name="UseActionProperties">
sqlmgt=sql#SqlMapManagerAction,true
performance=sql#SqlmapPerformanceAction,true
serverInfo=sql#ServerInfoAction,true
</attribute>
</service>
<!-- 서버정보 보기 -->
<service name="ServerInfo" code="com.sz.service.context.ServerInfoService">
</service>
<!-- 서버정보 보기 Action -->
<service name="ServerInfoAction"
code="com.sz.console.ui.ServerInfoViewAction">
<attribute name="ServerInfoServiceName">sql#ServerInfo</attribute>
<depends>sql#ServerInfo</depends>
</service>
<!-- 퍼포먼스 정보 보기 Action -->
<service name="SqlmapPerformanceAction"
code="com.sz.console.ui.PerformanceViewAction">
<attribute name="PerformanceServiceName">FSPManager#DBPerformanceManagerService</attribute>
<depends>FSPManager#DBPerformanceManagerService</depends>
</service>
</manager>
</server>
MiPlatform 스크립트 (2개의 데이터베이스에 접속하는 예)
function fn_searchPms()
{
//trace(ds_cond.SaveXML());
/*------------------------------------------------------
서비스 호출전 초기화 처리 (필수 호출)
-------------------------------------------------------*/
fsp_clear();
// 디폴트로 설정된 DB가 아닌 경우에는 코드상에서 아래처럼 설정이 필요함 (PMS서버로 접속)
fsp_setBiz("pmsBiz");
/*------------------------------------------------------
fsp_addSearch : 조회용 Action 정보 생성
* param1 조회할 SQL ID
* param2 조회한 결과는 Input Dataset으로 사용할지 여부
* param3 Dataset 컬럼 생성시 정렬할지 여부
-------------------------------------------------------*/
fsp_addSearch("common:Q0010_S01_S04"); // 이 SQL 문장은 pmsBiz 데이터베이스에서 실행됨
// 디폴트로 설정되지 않은 DB를 사용한 경우에는 반드시 해제하는 절차가 필요함 (원가서버로 초기화)
fsp_clearBiz();
//그리드 Sort Mark제거
gfn_clearGridSortMark(grd_pms_list,0);
/*------------------------------------------------------
fsp_callService : 서비스 호출 함수
* param1 : 서버에서 호출할 Action의 별명 (DEFAULT : DefaultAction)
* param2 : Action 안에서 호출해야 하는 메소드 명 (DEFAULT : execute)
* param3 : 서버로 전송할 DataSet 서버=로컬
* param4 : 서버로부터 전송 받을 DataSet 로컬=서버
* param5 : 서버로 전송할 기타 Argument 정보 예: key=value key2=value2
* param6 : 서버에서 처리가 완료된 후 Callback 받을 Function 명
* param7 : 처리중입니다. 메시지창 보여줄지 여부
* param8 : 동기처리 여부
-------------------------------------------------------*/
fsp_callService(
"",
"",
"ds_cond=ds_cond",
"ds_pms_list=ds_pms_list",
"",
"fn_AfterSearch"
);
}