Hello
Our application has a similar requirement that need to switch among
multiple datasources dynamicly, although we do not need to create
datasource in fly. We defined the datasources in ApplicationContex.xml,
then using getBean to load the datasource depand on the user's request
parameter and then set the datasource to the DAO's sqlMapClientTemplate
using setDataSource method. Also we need to define DAO as Singleton=false
to keep thread save.
Best Regards
Paul Sanders
<[EMAIL PROTECTED]
com> To
[email protected]
2007/04/14 06:27 cc
Subject
Please respond to Re: How can I change datasource
[EMAIL PROTECTED] connect info on the fly w/iBATIS
apache.org and Spring?
Interesting.... but you are right, our datasource info is not known in
advance though some are stored in a table and fetched at runtime when the
user selects it from a drop down in the browser. And of course they can
create one on the fly, too.
I wonder if the answer is to unwire the datasource from the DAO bean and
inject it by hand in the controller method. I lose the niceness of the
Spring framework for this particular task but I think it should work?
Paul
Chris Lamey wrote:
>
> Yea, Spring has a new AbstractRoutingDataSource that can route to a
> different datasource based on a ThreadLocal. The problem is that the
> iBATIS SqlMapClient doesn't know the datasource isn't the same between
> calls, so your caching gets horked.
>
> I don't know if it'll work for you because your datasources have to be
> known in advance and it sounds like yours may not be.
>
> Cheers,
> Chris
>
>
--
View this message in context:
http://www.nabble.com/How-can-I-change-datasource-connect-info-on-the-fly-w-iBATIS-and-Spring--tf3573169.html#a9986772
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
- How can I change datasource connect info on the fly w/iBATI... Paul Sanders
- Re: How can I change datasource connect info on the fl... Larry Meadors
- Re: How can I change datasource connect info on th... Chris Lamey
- Re: How can I change datasource connect info o... Paul Sanders
- Re: How can I change datasource connect in... Kyohyoh Choh
- RE: How can I change datasource conne... Chris Lamey
- RE: How can I change datasource c... Kyohyoh Choh
- Re: How can I change datasource connect info o... Paul Sanders
- Re: How can I change datasource connect in... Chris Lamey
- Re: How can I change datasource conne... Paul Sanders
- Re: How can I change datasource connect info o... tran duc trung
- Re: How can I change datasource connect in... Chris Lamey
- Re: How can I change datasource conne... tran duc trung
- Re: How can I change datasource c... Chris Lamey
- Re: How can I change datasour... tran duc trung
