java - 当从 UI 接收到带有 get 请求的数据库属性时,如何在运行时在 springboot 中配置数据源
问题描述
我有一个要求,其中用户通过 UI 输入数据库连接详细信息,如数据库类型(oracle、mysql、hive)、数据库 url、驱动程序名称、用户名、密码,这些连接详细信息作为GET 请求URL 参数传递给 Spring Boot 应用程序. 然后,我从 Spring Boot 应用程序连接到数据库,提取数据并发送回 UI。
用户可以输入任何数据库连接信息,因此这些详细信息在用户级别是动态的。如何在运行时使用这些用户输入详细信息动态连接到数据库。
GET Request: http://localhost:8080/api/getData
the following database properties sent from UI to spring boot application
{
dyType: 'hive',
dbUrl:'jdbc:hive2://localhost:10000/default;principal=hive/localhostDU',
driverClass: 'org.apache.hive.jdbc.HiveDriver',
username: 'xyz',
password: 'xxxxxxxx'
}
我想使用上述详细信息在运行时设置我的数据源。
解决方案
推荐阅读
- javascript - 如何使用带有节点列表的 Javascript 更改其他元素的样式
- javascript - Nginx“X-Accel-Redirect”以明文形式提供pdf
- javascript - 在 iframe 中的输入字段上键入会导致 iframe 滚动到底部
- python - Python随机数列表组织者
- azure-storage - Azure.Documents.Document - 找不到方法
- python - 2 树状图 + 来自 scipy 的压缩相关矩阵的热图
- azure-pipelines - Id 的任务定义的任务执行部分: .... 丢失或无效
- java - gson在反序列化JSON时如何将JSON键映射到Java类中的字段
- java - 如何从android中的firebase实时数据库中获取数据
- html - 在离子页面之间导航