I'm trying to access to seperate database from my application. How do I
configure iBatis to do this?
The problem that I'm running into is that when I define 2 <context>
sections in my dao.config I'm running into a collosion on the name of
the daoSessionHandler id tag.
Here is my dao.config file:
----------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<daoConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DaoConfig.xsd">
<providers resource="providers.config" />
<context id="SqlMapDaoVRL" default="true">
<properties resource="properties.config" />
<daoSessionHandler id="SqlMap">
<property name="resource" value="sqlMapVRL.config"/>
</daoSessionHandler>
<!-- ==== Sql Server : SqlClient configuration ========= -->
<database>
<provider name="sqlServer1.1"/>
<dataSource name="ShawContractVRL"
connectionString="
data source=${vrl_datasource};
database=${vrl_database};
user id=${vrl_userid};
password=${vrl_password};
connection reset=false;
connection lifetime=5; min pool size=1;
max pool size=50"
/>
</database>
<daoFactory>
<dao
interface="ShawCollections.Persistence.Interfaces.Collections.ICollectionDao,
ShawCollections.Persistence"
implementation="ShawCollections.Persistence.SqlMapDao.Collections.CollectionSqlDao,
ShawCollections.Persistence"/>
<dao
interface="ShawCollections.Persistence.Interfaces.SavedLayouts.ISavedLayoutDao,
ShawCollections.Persistence"
implementation="ShawCollections.Persistence.SqlMapDao.SavedLayouts.SavedLayoutSqlDao,
ShawCollections.Persistence"/>
</daoFactory>
</context>
<context id="SqlMapDaoPS">
<properties resource="properties.config" />
<daoSessionHandler id="SqlMap">
<property name="resource" value="sqlMapProductSearch.config"/>
</daoSessionHandler>
<!-- ==== Sql Server : SqlClient configuration ========= -->
<database>
<provider name="sqlServer1.1"/>
<dataSource name="ProductSearch"
connectionString="
data source=${ps_datasource};
database=${ps_database};
user id=${ps_userid};
password=${ps_password};
connection reset=false;
connection lifetime=5; min pool size=1;
max pool size=50"
/>
</database>
<daoFactory>
<dao
interface="ShawCollections.Persistence.Interfaces.Collections.IInstallationDao,
ShawCollections.Persistence"
implementation="ShawCollections.Persistence.SqlMapDao.Collections.InstallationSqlDao,
ShawCollections.Persistence"/>
</daoFactory>
</context>
</daoConfig>
----------------------------------------------------------------------------------------------------------------------
When I set the id property in
<daoSessionHandler id="SqlMap">
to anything other than "SqlMap" (ie. to my own made up id), the
application throws an error when it parses name='resource'. If I set
them both to the same id (SqlMap) they seem to overwrite each other so
that when I try to use the daoManager loaded from the first context
(SqlMapDaoVRL) it contains that maps and results of the second context
(SqlMapDaoPS).
Is there signifigance to the id that is used? In the docs (section
3.3.3.3 in DataAccess-doc-1.6.1.chm) it says that its "Id used to
uniquely identify the handler", but this doesn't seem to be the case.
I assume that I'm doing something wrong in my approach to making 2
databases work. I've looked through the docs and the archives and
cobbled what I have here together from those.
Can anyone shed some light on this?
Thanks!
Brian