I have a requirement wherein a user enters database connection details like database type(oracle, mysql, hive), database url, driver name, user name, password through an UI and these connection details are passed to spring boot application as GET request URL params. then, from the spring boot application, I connect to the database, extract the data and send back to UI.
Users can enter any database connection information, hence these details are dynamic at a user level. how can I connect to databases dynamically during runtime with these user input details.
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'
}
I want to set my datasource at runtime using above details.
question from:
https://stackoverflow.com/questions/65921536/how-to-configure-datasource-in-the-springboot-at-runtime-when-database-propertie 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…