at run time user give some databse details like IP, username, password. How Spring will connect to this database without restarting the server.
Get the datasource bean programatically after user input and set the values.
BasicDataSource newDataSource = new BasicDataSource();
newDataSource.setDriverClassName(request.getParameter("driverClassName"));
newDataSource.setUrl(request.getParameter("url"));
newDataSource.setUsername(request.getParameter("username"));
newDataSource.setPassword(request.getParameter("password"));
Also you can try using this example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.