Multiple data sources in spring
My spring-web.xml is like this
<!-- Data source Bean -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.ibm.as400.access.AS400JDBCDriver" />
<property name="url" value="jdbc:as400://localhost/BB" />
<property name="username" value="ROOT" />
<property name="password" value="ROOT" />
</bean>
My DAOImpl is like this
public class BBDAOImpl extends JdbcDaoSupport implements BBDao {
@Autowired
DataSource dataSource;
@Override
public List<Map<String, Object>> getDetails(String customerId) {
String sql = "<SQL Query>";
if(BBUtil.getInstance().isNotEmpty(customerId)) {
try {
return getJdbcTemplate().queryForList(sql,customerId);
} catch (EmptyResultDataAccessException e) {
logger.error("Empty result data - getDetails");
}
} else {
// Want to configure here from second data source
}
return null;
}
Here getJdbcTemplate() method is pointing directly to the AS400 DB(But how). Now, my another requirement has come up. In the else block I want to do some data manipulation from another SQL Server.
Can any one tell me how to configure multiple DB's in this and how to use them?
This project is already developed using XML configuration and now I cannot go back to annotations config.
Thanks in advance guys.