Allow ibatisnet to use multiple databases ___ database at the same time

Source: Internet
Author: User
Recent projects require the use of the ibatisnet framework, but databases need to use both Oracle and access, and many articles on the web are not covered. After one day of groping (analysis of the source code, testing), finally understand.
First, modify the Dao.config file, and here is an example:
<?xml version= "1.0" encoding= "Utf-8"?>
<daoconfig xmlns= "http://ibatis.apache.org/dataAccess" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" >
<providers resource= "Providers.config"/>
<context id= "Sqlmapdao" default= "true" >
<!--= = SQL server:sqlclient configuration =========-->
<database>
<provider name= "oracleClient1.0"/>
<datasource name= "Oracle" connectionstring= "User Id=gis; Password=gis;data Source=gis; "/>
</database>
<daosessionhandler id= "Sqlmap" >
<property name= "Resource" value= "Sqlmap.config"/>
</daoSessionHandler>
<daoFactory>
<dao interface= "XXBLL. Persistence.Interfaces.IQListItemDao, XXBLL "
Implementation= "XXBLL. Persistence.MapperDao.QListItemSqlMapDao, Xxbll "/>
<dao interface= "XXBLL. Persistence.Interfaces.IRoomInfoDao, XXBLL "
Implementation= "XXBLL. Persistence.MapperDao.RoomInfoSqlMapDao, Xxbll "/>
</daoFactory>
</context>
<context id= "Accessmapdao" default= "false" >
<!--= Access:oledb configuration
OleDb2.0 enable= "True" must be set in Providers.config
=========-->
<database>
<provider name= "OleDb2.0"/>
<datasource name= "Access" connectionstring= Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:/test/xxquery/app_ Data/test.mdb; "/>
</database>
<!--
Daosessionhandler default Id=sqlmap
If you want to specify a different dataaccesshandlers, you need to define the Daosessionhandlers configuration section.
-->
<daosessionhandler id= "Sqlmap" >
<property name= "Resource" value= "Sqlmap.config"/>
<!--<property name= "resource" value= "Sqlmap.config"/>-->
</daoSessionHandler>
<daoFactory>
<dao interface= "XXBLL. Persistence.Interfaces.IOAClassDao, XXBLL "
Implementation= "XXBLL. Persistence.MapperDao.OAClassAccessDao, Xxbll "/>
</daoFactory>

</context>
<!--
<daosessionhandlers id= "SqlMap1" >
Ioaclassdao Oaclassdao = Daomanager.getdao (typeof (Ioaclassdao)) as Ioaclassdao;
return Oaclassdao.getoaclasslist ();

Because the Oracle database is already specified by default in the Doa.config file, we need to specify the context configuration properties of the Accessmapdao in the Dao.config file.

OK, so we have successfully configured Ibatisnet to support multiple databases at the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.