I have an application which uses four databases in different geographical locations. All the databases contains same tables and only the database name is different according
As you have not tagged your question with any of this, hibernate
, JPA
, ORM
, I assume you are dealing with plain JDBC.
Having said that, I suggest you to have a DAO layer to deal with underlying databases, and leave the connection details to specific implementations. You can configure your connection strings in some .properties
files, lets say.
[Complement]
You can also make use of DAO factory, an implementation of Abstract Factory or Factory Method pattern, whichever suits here.
[Links]