I have a Java Web Application that currently uses a JDBC resource and connection pool to connect to a database. Currently, I only connect to one database at a time. I would like to be able to run the same code but connect to different databases by including something in the URL. I need to be able to still access my servlets by URL too. For example, the following links would run the same Servlet code, but for different databases. www.myapp.com/database1/Scheduling www.myapp.com/database2/Scheduling
I would like the database configurations to be outside of the web application, so that when I add a new connection or edit a connection, I don't have to rebuild my war file. I think I can do this by keeping the configuration file on the web server and editing that instead. I picture having the end user launch the app and choose the database they want to connect to. Once they choose, I could then grab the connection details.
There is also the possibility that a user could have 2 databases/links open at once, and I need to manage that/make it possible. I assume that would deal more with the Sessions.
I think I'm getting hung up on how I would be able to parse the database1 piece out of the URL and still be able to access the servlet. I understand how to map servlets in the web.xml file, but I don't know that what I'm describing is even possible.
I've been searching for a similar problem or question, but it seems the idea of having a web application that connects to different databases is more about accessing different components, such as a customer database and a product database.
Is what I am describing possible? Can this be accomplished in another way than I am describing?
I'm looking at Hibernate and also considered the Spring Framework. I think I'm a bit paralyzed at this point, not wanting to go down a path for something that isn't feasible or possible.
Thank you very much in advance