ssi连接两个数据库是的相关配型。主要是 两个不同的数据库 ,要在spring
1.db-config.properties
driverClass=com.mysql.jdbc.Driver
url=jdbc:mysql://192.168.1.7:3306/java
user=root
password=root
oracle.driverClass=oracle.jdbc.driver.OracleDriver
oracle.url=jdbc\:oracle\:thin\:@192.168.1.7\:1521\:jdbc
oracle.user=root
oracle.password=root
2.applicationContext.xml
<!--配置文件 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:db-config.properties"></property>
</bean>
<!-- 连接池 -->
<!-- mysql配置文件 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driverClass}"></property>
<property name="jdbcUrl" value="${url}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean>
<!-- oracle配置文件 -->
<bean id="dataSourceOracle" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${oracle.driverClass}"></property>
<property name="jdbcUrl" value="${oracle.url}"></property>
<property name="user" value="${oracle.user}"></property>
<property name="password" value="${oracle.password}"></property>
</bean>
<!-- 配置Ibatis核心对象 -->
<!-- mysql数据库 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocations">
<list>
<value>classpath:SqlMapConfig.xml</value>
</list>
</property>
</bean>
<!-- oracle数据库 -->
<bean id="sqlMapClientOracle" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSourceOracle"></property>
<property name="configLocations">
<list>
<value>classpath:SqlMapConfigOracle.xml</value>
</list>
</property>
</bean>