You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Manisha Sathe <ma...@yahoo.com> on 2005/01/24 10:04:53 UTC

Tomcat 5 - Datasource Connection Pooling

Finally after long struggle I could get the datasource things running. 
 
The things are working when i specified all into GlobalResources and 
GlobalContext inside server.xml 
 
My server.xml is something like below..
 
-----------------------------------------
<GlobalNamingResources>
<Resource auth="Container" name="mspool" type="javax.sql.DataSource"/>
    <ResourceParams name="mspool">
      <parameter>
        <name>url</name>      
<value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sbcs</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>30</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>100</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>10000</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>manisha</value>
      </parameter>
      <parameter>
        <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
      </parameter>
      <parameter>
        <name>selectMethod</name>
        <value>cursor</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>manisha</value>
      </parameter>
      <parameter>
        <name>removeAbandoned</name>
        <value>true</value>
      </parameter>
      <parameter>
         <name>removeAbandonedTimeout</name>
         <value>60</value>
       </parameter>
       <parameter>
          <name>logAbandoned</name>
          <value>true</value>
       </parameter>
    </ResourceParams>
  </GlobalNamingResources>
.......
....
      <Host appBase="webapps" name="localhost">
        <DefaultContext 
className="org.apache.catalina.core.StandardDefaultContext">
          <ResourceLink global="mspool" name="mspool" 
type="javax.sql.DataSource"/>
        </DefaultContext>
        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." 
suffix=".txt"
            timestamp="true"/>        
      </Host>      
....
 
I did not change anything inside Web.xml as everything is inside 
Global.
 
But i do not want it inside global naming resources / default context - 
but i want it only specific to my web application. i also understand 
that <Context> - should not be used for TomCat5.0 - but need to put 
inside /META-INF/context.xml.
 
1)My problem is my working directory is different. I use ant to create 
war file and then i manually stop the server - delete existing war file 
/ existing directory (This is due to some Win TomCat problem .??..). 
Then i deploy it using TomCat Manager. It automatically creates META-INF 
file for me, i do not have META-INF inside my working directory. So 
where i can put my context.xml ?
 
2) What shall i put inside context.xml and what shall i put inside 
server.xml / web/xml ?
 
I tried many different ways but when i use context and as there is no 
such application (because i delete and re-deploy it) - tomcat server 
does not run my application. 
 
Pls guide me
 
regards
Manisha


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Tomcat 5 - Datasource Connection Pooling

Posted by "Trond G. Ziarkowski" <tr...@gep-as.com>.
Hi!

>1)My problem is my working directory is different. I use ant to create 
>war file and then i manually stop the server - delete existing war file 
>/ existing directory (This is due to some Win TomCat problem .??..). 
>Then i deploy it using TomCat Manager. It automatically creates META-INF 
>file for me, i do not have META-INF inside my working directory. So 
>where i can put my context.xml ?
>  
>
You have already answered this yourself, META-INF/ directory of your war 
file.
The only way to avoid the META-INF directory is to not use a war file, 
as a war file simply is a jar file, and the META-INF is part of the jar 
file specification.

>2) What shall i put inside context.xml and what shall i put inside 
>server.xml / web/xml ?
>  
>
The example pages: 
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html 
tells you exactly what to put in each file. You just have to read them 
one more time and keep focused.
I'll give you some hints as well:
- Leave server.xml the way it was before you started tampering with it.
- Copy CATALINA_HOME/conf/<enginename>/<servername>/yourapp.xml, to your 
context.xml file, and add your resource specification inside the 
<context> as in the examples. Then include context.xml in your war file 
in the META-INF dir. Your app must be running for the yourapp.xml file 
to exist as it is deleted when you undeploy your app.
- In web.xml you need to add a <resource-ref> as you can see from the 
examples


Good luck

Trond


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org