we have exactly the same need and has created code to hold a hashmap of connections, which seems to be working. However, what will happening if we were to introducing caching, will the different objects from different databases be mixed together?
Jeff Butler-2 wrote: > > What you're doing with the HashMap is very similar to what the DAO manager > does with multiple contexts. So you're right - that won't buy you > anything. What's causing the overhead is that you're loading the SqlMap > configuration into memory 100 times - once for each database. Multiple > contexts in a DAO configuration would do the same thing. > > If the database schemas are the same and only the connection is different, > then you could use the setUserConnection method to supply the connection > at > run time. So then you would only need to load the SqlMap configuration > into > memory one time, keep a HashMap of connections, then set the connection > before calling SqlMap functions. > > Jeff Butler > > > > > > On 10/23/06, Barnett, Brian W. <[EMAIL PROTECTED]> wrote: >> >> We have an app that currently services over 100 different customers, >> each >> having their own SQL Server or Oracle database. We host the web app and >> the >> databases on our servers. >> >> The solution we came up with a few years ago was to have a HashMap of >> DaoManager objects, one DaoManager object for each database, keyed by >> customer name in the HashMap. With the 100+ customers we have now, these >> daoManager objects consume around 400Meg of memory total. Obviously, as >> our >> customer base grows, this will eventually kill us. >> >> So the question we have is, "Does a dao, or DaoManager, have to be tied >> to >> a single database?" I suspect this may not be the correct question, but >> it >> is the only one I can come up with right now. Wondering if we can have >> one >> DaoManager and when we request a dao, also tell the manager which >> database >> we want the dao to operate on. >> >> Is there a better way to handle this situation? I've read that you can >> use >> multiple contexts in the dao.xml file, but I'm not sure if this would >> solve the memory problem we are having. >> >> We are currently running iBatis 2.1.0. >> >> TIA, >> Brian Barnett >> >> **************************************************************************** >> >> >> This email may contain confidential >> material. If you were not an intended recipient, >> Please notify the sender and delete all copies. >> We may monitor email to and from our network. >> >> >> *************************************************************************** >> >> >> > > -- View this message in context: http://www.nabble.com/Does-dao-have-to-be-tied-to-a-single-database--tf2497965.html#a7165371 Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
