tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Marshall" <scott.marsh...@interserve.com>
Subject How do I match the database Resource in the Context depending on the development environment ?
Date Thu, 14 Jun 2007 15:48:02 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message