You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Scott Marshall <sc...@interserve.com> on 2007/06/14 17:48:02 UTC

How do I match the database Resource in the Context depending on the development environment ?

Hi all

 

I'm using Tomcat 5.5, and am setting up Connection pools for the
database, using the context.xml file from the META-INF directory. 

We do / will have a multi region series of dev environments  (local,
dev, UAT, PAT, Live etc) as the code gets developed.

Each Resource will point to a different database, and need different
connection settings, e.g

 

<?xml version="1.0" encoding="UTF-8"?>

 <Context crossContext="true" debug="5" path="/ipsl_app"
reloadable="true">

    <Resource

          name="jdbc/connectionPool"

          auth="Container"

          type="javax.sql.DataSource"

          driverClassName="net.sourceforge.jtds.jdbc.Driver"

          factory="org.apache.commons.dbcp.BasicDataSourceFactory" 

          user="sa"

          password="sandstone"

          maxIdle="2"

          maxWait="5000"

 
url="jdbc:jtds:sqlserver://testheat.company.com:1433/test;user=sa;passwo
rd=test"

          maxActive="4"

          removeAbandoned="true" removeAbandonedTimeout="60"
logAbandoned="true"/> 

   </Context>

 

 

My question is how do I put multiple Resource elements within the
Context element, and ensure the correct Resource is read for the correct
environment ? 

The only real idea I have so far on how to do this is to use a different
'name' attribute values for each Resource, and determine which 'name' to
select based on the value in a properties file that would say which
environment (dev, Live) was in use.  

 

But I can't be the first one to run into this problem, and Google wasn't
any help. Can anyone give me any hints on how they've done it, or if
there's a best practice ? The Tomcat documentation wasn't any real help,
and I don't want to have to edit the file before deployment etc. If I'm
on the wrong track completely , let me know.

 

Thanks very much

 

Scott

 



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

Re: How do I match the database Resource in the Context depending on the development environment ?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Scott,

Scott Marshall wrote:
> I'm using Tomcat 5.5, and am setting up Connection pools for the
> database, using the context.xml file from the META-INF directory. 
> 
> We do / will have a multi region series of dev environments  (local,
> dev, UAT, PAT, Live etc) as the code gets developed.

We use different context.xml files for each environment. We use ant to
build everything, so it's as simple as setting "release-type=prod" and
then all of the configuration comes out of the "prod" directory.

Since we place no restrictions on the value of "release-type", you can
set it to anything you like and files will be pulled from the
"conf/[whatever]" directory and put into the WAR (or wherever).

This requires some work with ant to get things set up, but I think it's
completely worth it.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGcWSF9CaO5/Lv0PARAsdMAJ4tPoj6g0UK0vUNFH8scD8qs/S7rgCdEv41
GN1yn3pMq9ghSTmm5IlA4s0=
=OVar
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org