You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by David McReynolds <da...@gmail.com> on 2008/10/21 15:53:36 UTC

duplicate databases

Precondition: I know this is a screwy set up. But, it is, what it is. What I
need, are ideas for dealing with it, and any heads up dor potential
nightmares.

We have two databases that are supposed to remain synchronized. For some
reason, there is no abstraction layer (hardware or otherwise) that presents
the databases as one to the application layer.

What I have done so far, is create two sqlMapConfig files which define the
two datasources and include the map files.

Then, I have an SqlMapClientFactory that accepts a "resourceName" and a
"resourceType", the latter being "Primary" or "Secondary", the former being
one of many different datasources the application must deal with.

Finally, I altered the iBator generated DAO constructors to accept the
"resourceName". Then each method has to be get the SqlMapClient instance
from the factory (which is caching the references: Primary and Secondary).
The bodies of the DAO methods are written with try/catch and the catch
blocks attempt the same operation but with the "Secondary" SqlMapClient.
Only if the secondary fails is the standard ibatis sql exception allowed to
propagate up.

--
dlm

Re: duplicate databases

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
If I get it right you need to execute same statements to multiple (two)
databases. Have a look at http://ha-jdbc.sourceforge.net/. I have NOT used
it, but it seems to be an easy and transparent way to achieve what you need.