ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bhaarat Sharma <bhaara...@gmail.com>
Subject Re: how to have two datasources in sql-map-config.xml
Date Fri, 01 May 2009 18:24:26 GMT
also, we have a spring-for-ibatis.xml file where we have code like this
<bean id="IbatisDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/RSGH/IJA/twy/ftwdb"/>
</bean>

<bean id="BTHSqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sql-map-config.xml"/>
  <property name="dataSource" ref="IbatisDataSource"/>
 </bean>

 <bean id="UsageIfaceDAO"
class="biv.data.dao.reports.auditreports.UsageReportDAO">
    <property name="sqlMapClient" ref="BTHSqlMapClient"/>
    <property name="dataSource" ref="IbatisDataSource"/>
 </bean>

so can I then just add another bean with jndi like this:
<bean id="IbatisDataSource2"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/RSGH/IJA/twy/<mynewDBNAME>"/>
</bean>

then another bean for sql-map-client (I will have to make another xml right?
say sql-map-client1.xml)
<bean id="BTHSqlMapClient1"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sql-map-config1.xml"/>
  <property name="dataSource" ref="IbatisDataSource"/>
 </bean>

and then start registering my DAO's like this
 <bean id="SomeNewDAO"
class="biv.data.dao.reports.auditreports.SomeReportDAO">
    <property name="sqlMapClient" ref="BTHSqlMapClient1"/>
    <property name="dataSource" ref="IbatisDataSource"/>
 </bean>

Thanks
-bhaarat
On Fri, May 1, 2009 at 2:09 PM, Bhaarat Sharma <bhaarat.s@gmail.com> wrote:

> Hi
> Currently our sql-map-config looks like this:
>
> <sqlMapConfig>
>    <settings enhancementEnabled="true" useStatementNamespaces="true" />
>  <transactionManager type="JDBC">
> <dataSource type="JNDI">
>  <property name="DataSource" value="jdbc/RSGH/IJA/twy/ftwdb" />
> </dataSource>
>  </transactionManager>
>  <sqlMap resource="existingSearch.xml" />
>         <sqlMap resource="deceased_search.xml"/>
>         <sqlMap resource="multiLoanSearch.xml"/>
> </sqlMapConfig>
>
> In the above we only have one JDBC connection and this connection goes to a
> SQL Server.  However, now we will have to access another DB which is in
> Oracle.  So we will have to create another JDBC connection and have some of
> our sqlMaps reference that NEW JDBC connection.  Can this be done in iBatis?
> can we have multiple data sources, and if so, then how do
> we differentiate which DB a sqlMap references.
>
> Thanks!
>

Mime
View raw message