How to create Dynamic connections (datasource) in spring using JDBC

天涯浪子 提交于 2019-12-04 14:14:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!