How to connect another database in maven project at the time of login, after building the war with one database?

Initially the war was build with production database. In the login web service, we have one parameter to specify the application to connect the production db or training db. If the user gives the production db as the parameter, then there is no problem. Else if user gives training db as the parameter, then how to connect and get/update in the training db. Is it possible to do in the maven project?