For multiple application sharing common resource, instead of defining resource in each context xml can be defined globally to share with all context in same tomcat container.
Pro/Cons: Change @ one place will reflect in all application context
Steps:
- Define resource in <tomcat-home>/conf/server.xml
<GlobalNamingResources>
<!--
<!--
other resources
-->
<Resource name="jdbc/hcentivePHIXDS" global="jdbc/hcentivePHIXDS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="25" maxWait="10000"
username="username" password="password" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl" factory="org.apache.commons.dbcp.BasicDataSourceFactory" />
</GlobalNamingResources>
<Resource name="jdbc/hcentivePHIXDS" global="jdbc/hcentivePHIXDS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="25" maxWait="10000"
username="username" password="password" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl" factory="org.apache.commons.dbcp.BasicDataSourceFactory" />
</GlobalNamingResources>
- Define resource link in <tomcat-home>/conf/context.xml
<context>
<!--
other elements
-->
<ResourceLink type="javax.sql.DataSource"
name="jdbc/hcentivePHIXDS"
global="jdbc/hcentivePHIXDS"/>
name="jdbc/hcentivePHIXDS"
global="jdbc/hcentivePHIXDS"/>
</context>
No comments:
Post a Comment