davidcnoel
Nov 17th, 2005, 12:51 PM
An application I am starting to work on requires that I am able to connect to many different databases. I plan on using the standard Dao pattern but my problem is that I will not know which databases I am supposed to talk to until runtime. This will mean that I cannot configure my datasources in the usual fashion in a spring context. Is there any standard pattern to follow to solve this problem? I was thinking I would create a factory type of object that would manage multiple datasources. Basically you would request a datasource for a database with the name 'A' and it would create the datasource if it did not exist or return a reference to a datasource from the "pool" if it did exist. Even If I do this I still have a problem that the existing DaoSupport classes that spring provides only work with a single datasource. So I would think I would need some type of factory that would create a new instance of my Dao object for the particular datasource I want to talk to. I'm also going to want to take advantage of transactions through Spring AOP so I need to make sure I consider this as well.
I'm thinking this is a common issue so I hope there is an existing best practice or pattern to follow.
Any ideas?
Thanks
Dave
I'm thinking this is a common issue so I hope there is an existing best practice or pattern to follow.
Any ideas?
Thanks
Dave