Environment: Spring3.1+ibatis2.3.4+oracle+hbase
Requirement: Need to operate two different data sources in the project, one is MSSQL, the other is hbase.
Realize:
<bean id= "Hbasedatasource" class= "Org.apache.commons.dbcp.BasicDataSource"
destroy-method= "Close" >
<property name= "Driverclassname" value= "Org.apache.phoenix.jdbc.PhoenixDriver"/>
<property name= "url" value= "Jdbc:phoenix:IP"/>
</bean>
<!--database connection pool--
<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource"
destroy-method= "Close" >
<property name= "Driverclassname" value= "Com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name= "url"
Value= "Jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;databasename=xxx"/>
<property name= "username" value= "sa"/>
<property name= "Password" value= "xxxxxxx"/>
</bean>
<bean id= "sqlmapclient" class= "Org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
<property name= "configlocation" value= "Sql-map-config.xml"/>
<property name= "DataSource" ref= "DataSource"/>
</bean>
<bean id= "Sqlmapclientforhbase" class= "Org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
<property name= "configlocation" value= "Sql-map-config-hbase.xml"/>
<property name= "DataSource" ref= "Hbasedatasource"/>
</bean>
<bean id= "Baseservice" class= "Xxx.xxx.serviceimpl.base.BaseServiceImpl" >
<property name= "sqlmapclient" ref= "Sqlmapclient"/>
</bean>
<bean id= "Baseserviceforhbase" class= "Xxx.xxx.serviceimpl.base.BaseServiceImpl" >
<property name= "sqlmapclient" ref= "Sqlmapclientforhbase"/>
</bean>
Tags: spring,ibatis
spring+ibatis+ Multiple data sources