Your dao.config file should look more like this:

<?xml version="1.0" encoding="utf-8"?>
<daoConfig
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="DaoConfig.xsd">
 <context id="SqlServer">
  <daoSessionHandler id="SqlMap">
   <property name="sqlMapConfigFile" value="SqlMap.config"/>
  </daoSessionHandler>
  <database>
   <provider name="sqlServer1.1"/>      
   <dataSource name="SqlServer"
connectionString="data source=HOST;database=DB;user
id=USER;password=PASS;"/>
   </database>  
   <daoFactory>
    <!-- you need add dao nodes to map interfaces with implementations
-->
   </daoFactory>
 </context>
 <context id="Oracle">
  <daoSessionHandler id="SqlMap">
   <property name="sqlMapConfigFile" value="OracleMap.config"/>
  </daoSessionHandler>
  <database>
   <provider name="oracleClient1.0"/>   
   <dataSource name="OracleServer"
connectionString="Data Source=SERVICE;User
Id=USER;Password=PASS;Integrated Security=no;" />
  </database>   
  <daoFactory>
   <!-- you need add dao nodes to map interfaces with implementations
-->
  </daoFactory>
 </context>
</daoConfig>

You request a specific dao using its context id:

 DaoManager sqlServerDaoManager = DaoManager.GetInstance("SqlServer");
 DaoManager oracleDaoManager = DaoManager.GetInstance("Oracle");

You need to add dao nodes to your daoFactory nodes so you can request
interfaces from the dao manager object:

 IUserDao userDao = (IUserDao)oracleDaoManager[typeof(IUserDao)];
 IList users = userDao.GetMany();

In your provider.config file, having two provider nodes each marked
with:

 default="true"

may cause problems.

In OracleMap.config, the database node:

 <database>
  <provider name="oracleClient1.0"/>    
  <dataSource name="OracleServer" connectionString="..." />
 </database>    

is ignored when using dao objects so you can comment it out or remove
it.

I would verify that IBatisNet is working the way you want before trying
to integrate it with Spring.
        
--- Jess Nielsen <[EMAIL PROTECTED]> wrote:

> Hi there
> 
> I'm trying to configure ibatis so it wil be using two different
> databases (oracle and sqlserver) concurrently. I have been using
> several
> hours on this without success and hope that some of you guys in here
> can
> help me. The error I keep getting is the usual:
> Spring.Objects.Factory.ObjectCreationException
> 
> The connection to the SQL Server is working out of the box, when the
> Oracle configuration hasn't been added. As soon as I add the
> configuration for the Oracle it will fail. Does anyone know how to
> configure ibatis so the setup will work?
> 
> I hope for a soon reply on this.
> 
> Thanks in regards,
> Jess

Reply via email to