Something seems off about that. It sounds like you have a webapp with hard-coded database connection information in it. The only excuse for ever doing that in my book would be if the app is a general-purpose database editor, and definitely not a Hibernate app.
Ordinarily
you should be using a
JEE Database Connection Pool, and Connection Pools should not be part of the webapp, but instead part of the webapp server. You can share a single pool between multiple webapps, and define the pool in Tomcat's conf/server.xml file, but more often each webapp would have its own associated pool, defined in that webapp's
server-dependent deployment information.
JEE defines 2 sets of deployment data for every deployed webapp. The server-
independent deployment data, which is
/WEB-INF/web.xml including data dynamically added to it via annotations.
The server-
dependent deployment data, is, as its name indicates variable depending on what webapp server you use. For Tomcat, it's contained in a
Context XML element. The Context element can be defined in a file in the WAR:
/META-INF/context.xml and/or supplied externally, in which case the WAR Context is overridden. A Context is generated automatically when you drop a WAR into
TOMCAT_HOME/webapps, but it's minimal and will not include database connection pool info.
For maximum flexibility, use an external Context XML file. By default, this will be located in the TOMCAT_HOME/conf/Catalina/localhost directory and be named "something.xml", where "something" is the context path name that the webapp will be deployed under. The contents of that file, like those of the WAR context file are a single Context XML element and its children.
And THAT, is where you'd define your webapp's connection pool(s).
Note that since the external context file is indeed external to the WAR, you can re-target database servers without updating the WAR. That's my standard practice for having the same WAR file used for
testing and production, which cuts down on confusion and possible security problems arising from building custom for each environment.
I use Spring Data JPA with Hibernate JPA, and Spring will automatically inject the pool service point into the webapp via JNDI, but if you're not using Spring, you can always look up the pool and connect it manually as part of your app startup code.