私のアプリケーションには (仮説として) 次のサーバーがあります。私はMySQLを使用しています。
1) アプリケーションが使用するデータベース (日本にあるサーバー)
2) データベースのバックアップ (ペルーにあるサーバー)
3) 緊急データベース (米国にあるサーバー)
Spring の機能についていくつか質問があります。
A) すべてのデータソースで同時に保持するにはどうすればよいですか?
B) Spring で接続プールを作成して、最初のデータソースが応答しない場合にシステムが自動的に 2 番目のデータソースで動作するようにするにはどうすればよいですか?
これが私の実際のapplicationContext-datasource.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>META-INF/database.properties</value>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}"/>
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>
よろしく