如何使用JDBC在spring中创建动态连接(datasource) [英] How to create Dynamic connections (datasource) in spring using JDBC
问题描述
我有一个spring应用程序,我需要获取oracle表的服务器详细信息,并根据某些服务器ID,需要创建动态连接,
我该如何使这项工作?
看看Spring的 AbstractRoutingDataSource
( javadoc-api )。这允许您维护一个路由器 c> dataSource bean,它将能够基于提供的单个属性在运行时路由到所需的真实数据源(在您的情况下,它将是
这里有更多关于 AbstractRoutingDataSource
:动态数据源路由
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?
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
这篇关于如何使用JDBC在spring中创建动态连接(datasource)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!