Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Switch datasources using spring?  RSS feed

 
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
Boost this thread!