The way we handle this:
- Have the client create a connection pool in GlobalNamingResources using a resource name we agree on. The database driver needs to be in Tomcat's classpath.
- Our war file includes a META-INF/context.xml files that has a ResourceLink linking to the connection pool configured in step 1.
This is a little more up front work than simply altering the context.xml connection information directly, but over time it should pay off. A development server would be setup with it's GlobalNamingResources pointing to development, and a test server point to test etc. Then, the same WAR file can be copied to each server without editing anything.
This isn't using properties files, but I think it achieves the same goal. Allowing a user/customer to setup the database connection information.
Example of GlobalNamingResource:
<Resource name="jdbc/dbconnection" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1546:SID"
username="scott" password="tiger" maxActive="8" maxIdle="4"
validationQuery="select 1 from dual"
testOnBorrow="true"/>
Example of context.xml in war file:
<Context path="/MyWebApp" docBase="MyWebApp" debug="5" reloadable="true">
<ResourceLink name="jdbc/dbconnection" global="jdbc/dbconnection"
type="javax.sql.DataSource"/>
</Context>