I have developed an application in java and i use tomcat. In this web application, i declared in web.xml this resource :
<resource-ref>
<description>My datasource</description>
<res-ref-name>jdbc/myDS1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
When i build my application, i get a war. i copy this war and deploy both of them in tomcat : app1.war and app2.war
Then i define app1.xml and app2.xml where i define the datasource but with different connection information :
for example app1.xml :
<Context crossContext="true" reloadable="true">
<Manager className="org.apache.catalina.session.StandardManager" saveOnRestart="false"/>
<Resource
auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxActive="20"
maxWait="5000"
name="jdbc/myDS1"
username="USER_APP1"
password="PASS_APP1"
type="javax.sql.DataSource"
url="... My Server ...."
defaultAutoCommit="false"
validationQuery="SELECT 1 FROM DUAL"/>
</Context>
The same for App2.xml but with different user and pass.
In this way, i can bind different datasource to different instance of my war without modify them.
I would like to do the same in Jboss 4. I know that Jboss is using tomcat. Is there a way to reuse my tomcat conf file ?
No comments:
Post a Comment