There will be scenarios where you need to fetch data from external data sources (schemas) other than the implementation database. In such scenarios, perform the following:
Create a configuration file (XML) for the external database and define the data source for it.
While defining the data source in the configuration file for the external database, use the following naming convention - <external db name>_DS, e.g. EXTDB_DS.
For example, the following sample shows a sample configuration file (ExtDBConfig.xml) for the external database:
ExtDBConfig.xml<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <properties resource="databaseconfig.properties" /> <transactionManager type="EXTERNAL"> <property name="SetAutoCommitAllowed" value="false"/> <dataSource type="JNDI"> <property name="DataSource" value="${EXTDB_DS}"/> <!-- EXTDB_DS is the data source for the external database. --> </dataSource> </transactionManager> <sqlMap resource="com/intellectdesign/canvas/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/viewdefn/Default_Function_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/canvas/database/ibatis/common/maps/viewdefn/Default_SqlMap.xml" /> <sqlMap resource="com/intellectdesign/modelhouse/database/ibatis/${CT_FW_DATABASE_VENDOR}/maps/Payments.xml" /> </sqlMapConfig>
Update the databaseconfig.properties file to specify the configuration for the external database. The following code snippet shows a sample configuration:
# Specify the external database in CT_IBATIS_DATASOURCE_KEYS. CT_IBATIS_DATASOURCE_KEYS = CT_MODEL_HOUSE,EXTDB #EXTDB is the key for external database # Specify the data source to be used for the external database (as specified in the configuration XML file). EXTDB_DS = java:comp/env/jdbc/EXTDB # Specify the configuration file for the external database. EXTDB_DSXML = com/intellectdesign/modelhouse/database/ibatis/config/ExtDBConfig.xml