问题
I have a a spring application where i need to get server details for a oracle table and create dynamic connections as and when require based on some server id, How can I make this work?
回答1:
Take a look at Spring's AbstractRoutingDataSource
( javadoc-api ). Which allows you to maintain a "router" dataSource
bean that would be able to route to a required real dataSource at runtime based on a single property provided ( in your case it would be a server id
).
Here is more about AbstractRoutingDataSource
: Dynamic DataSource Routing
来源:https://stackoverflow.com/questions/7494828/how-to-create-dynamic-connections-datasource-in-spring-using-jdbc