at run time user give some databse details like IP, username, password. How Spring will connect to this database without restarting the server.
Asked
Active
Viewed 232 times
0
-
Please refer this link http://stackoverflow.com/questions/13507522/dynamically-change-spring-data-source – Karthik Prasad Jan 03 '14 at 09:40
-
In your above answer there is ony two databse major or minor but in my case i dont know which database IP,username and password user will give. – user2790517 Jan 03 '14 at 09:45
1 Answers
0
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

Community
- 1
- 1

Sureshkumar Panneerselvan
- 749
- 6
- 22
-
Your answer sounds good. but In my project i have two basicdatasource server and client. So Give some example link how can i connect through programmetically setting up users details about database. – user2790517 Jan 03 '14 at 09:49
-
In your above examplethere is only three databse major or minor but in my case i dont know which database IP,username and password user will give. – – user2790517 Jan 03 '14 at 09:53