Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Switch datasources using spring?

 
Damien Biggs
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i'm wondering if its possible to do this at runtime. I have two datasources (dev and dit). I am using an ibatis SqlMapClientFactoryBean. Typically the dev datasource is wired into this at startup. What I want to know is if it is possible to programmatically change the datasource at runtime.

I've tried using the code below. I retrieve a DriverManagerDataSource from the database and update the beans in the applicationContext that use a datasource. It doesn't however change the datasource being used.

manager.setDataSource(newDaoSource);
factoryBean.setUserConnection(newDaoSource.getConnection());

Any help would be brilliant.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the JDBC forum is a better fit for this question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic