Monday, 15 February 2010

mysql - Configuring a fall back datasource in RESTLet DAO Client Server Architecture In Java -


I have a Restlet DAO client server architecture in Java, and a JDBC MySQL data source with Apache Tomcat 7.0 deployed server I am here. My master database is online, while the repeated slave database (read only) is on the local lane

The server must start between the two available databases at startup - if online (Master) is accessible, then connects with it, otherwise the local DB

We do not have internet connection, we connect to local DB. Now how do I switch to Online DB after coming back to the Internet? And switching should also be done on the reverse scenario, i.e. first we have internet and then there is no internet.

I think you should apply a custom DataSource (JDBC's Implementation interface Datasource ) that acts as a proxy in front of two target data sources (one for local remote for DB and one for remote).

In this scenario, let us apply a method to check whether there is an internet connection or not.

You can see that in order to communicate with the database you need the basis of the DAO classes at the data source. Dependence injection or factory pattern can be useful here ...

Hope this will help you, Thierry


No comments:

Post a Comment