mardi 17 juillet 2018

How to create connection for two different data sources in singleton class in java

I have one class name DBManager.java, this class implements a singleton design pattern and this is used for all DB operations. This works perfectly when I have to connect with 1 data source, Now in my project, I have to connect with 2 different data sources, Now when I use this class, this behaves differently. because it always returns 1 data source connection.

Now how can I manage this, in a better way? One approach is I would create another DBManager2.java class and use this class for the 2nd data source, but I don't think so it's a good way.

Any recommendation.

Aucun commentaire:

Enregistrer un commentaire