Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There will be scenarios where you need to fetch data from external data sources (schemas) other than the implementation databaseschema. In such scenarios, perform the following:

  1. Create a configuration file (XML) for the external database schema and define the data source for it.

    Note

    While defining the data source in the configuration file for the external databaseschema, use the following naming convention - <external db schema name>_DS, e.g. EXTDB_DS.

    For example, the following sample shows a sample configuration file (ExtDBConfig.xml) for the external databaseschema:

    Code Block
    languagexml
    titleExtDBConfig.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 databaseschema. -->
    		</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>


  2. Update the databaseconfig.properties file to specify the configuration for the external schema. The data source name and the JNDI for the new data source should be configured in the databaseconfig file and the same data source name has to be used in the database configuration XML.

    The following code snippet shows a sample configuration:

    Code Block
    languagebash
    # Specify the external databaseschema in CT_IBATIS_DATASOURCE_KEYS.
    CT_IBATIS_DATASOURCE_KEYS = CT_MODEL_HOUSE,EXTDB # #EXTDBEXTDB is a thesample keydata forsource externalkey database
    
    # Specify the data source to be used for the external database schema(as specified in the configuration XML file).
    EXTDB_DS = java:comp/env/jdbc/EXTDB
    
    # Specify the configuration file for the external database. schema in the following key format - <DATA_SOURCE_KEY>_<DSXML>:
    EXTDB_DSXML = com/intellectdesign/modelhouse/database/ibatis/config/ExtDBConfig.xml


...