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??


Reply via email to