Hi,

I am using JDBCTemplate to connect to a datasource which has failover between two databases. When one database goes down the other takes the load.

How would you support this the best way using Spring and JDBCTemplate?

In my DAO object I have a method like

Code:
@Autowired
@Qualifier("dummyDataSource")
public void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
}
And in my applicationContext.xml the different parameters for the datasource is specified.

Code:
<bean id="dummyDataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.mssql.driverClassName}"/>
    <property name="url" value="database1url"/>
    <property name="username" value="username"/>
    <property name="password" value="password"/>
</bean>
The problem is obviously that if database1url goes down, i want it to try database2url instead. What would be the best way to do this?

Thanks for your help.