You can do it better. In our case, we had different databases for different profiles, such as dev, UAT, pre-prod, support, etc.
So what I did, I put my context.xml in its default location <TOMCAT_HOME>/conf .
The following was specified in the configuration of the context.xml resource:
<Resource name="jdbc/someDS" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="${appName.db.url}" username="${appName.db.user}" password="${appName.db.password}" maxActive="30" maxIdle="10" defaultAutoCommit="true" maxWait="-1"/>
I created three tomcat servers - server-dev, server-uat, server support and passed the corresponding values ββfor each database in the vm tomcat arguments in the eclipse / intellij tomcat configuration (as shown below):
-DappName.db.url=jdbc:oracle:thin:@<DB_SERVER>:1521:<SID> -DappName.db.user=DB_USER -appName.db.password=DB_PASSWORD
The advantage is that developers then do not need to change the database every time, they just need to start a specific server. It was very convenient and saved a lot of time during our development.
avijendr
source share