I have never done something like this, but this would be likely to be a
valid path:
- configure a data source in the servlet container and bind it to jndi.
Do not try to configure it in the context of one of your applications.
I do not know for sure whether this works for tomcat, but it works for
other application servers. Ask the tomcat documentation. Torque is not
needed for this step.
- use a torque.properties in both applications, and reference the data
source via jndi (i.e. use JNDIDataSourceFactory for it)
- make sure each of the applications calls Torque.init() on startup.
In this method, the data source is found in jndi and is made usable in the
application.
Thomas
On Fri, 2 Dec 2005, Anuradha S.Athreya wrote:
I am trying to configure connection pooling using Torque for 2 web
applications deployed in the same tomcat container but in 2 different
contexts, connecting to the same database.
Doubt 1: Where should the Torque.properties file be located? Obviously, the
path of this file has to be with reference to a servlet context. Since I
want to create a common connection, which one of the 2 servlet context will
contain the properties file?
I made changes to the Tomcat server.xml file :
<Context path="/myApp1" docBase="D:/jakarta-tomcat-5.0.18/webapps/myApp1" >
<Resource name="jdbc/myApp1"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/myApp1">
<parameter>
<name>factory</name>
<value>org.apache.torque.dsfactory.JndiDataSourceFactory</value>
</parameter>
<!-- DBCP database connection
settings -->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/myApp1DB</value>
</parameter>
<parameter>
<name>driverClassName</name><value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>myApp1</value>
</parameter>
<parameter>
<name>password</name>
<value>myApp1</value>
</parameter>
<!-- DBCP connection pooling options
-->
<parameter>
<name>maxWait</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
</ResourceParams>
</Context>
Under normal circumstances, since i place the war files of the application,
I dont specify the CONTEXT explicitly in the server.xml file. But since. I
need to place RESOURCE tag, here I added the CONTEXT tag.
Since, I have 2 web applications deployed, will I have to repeat the CONTEXT
tag again for my 'myApp2'??
I have also made changes to the web.xml file :
Added :
Next comes the connection part....
Will Tomcat itself perform Torque.init()?
If not, where should this be done, so that the Torque initialisation happens
common to both the applications??
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]