You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Vsevolod (Simon) Ilyushchenko" <si...@cshl.edu> on 2005/09/13 17:35:54 UTC
Different JDBC sources?
Hi,
As a relative Tomcat newbie, I can't find anything about how to use two
different JDBC sources with the same codebase. I'd like to have two
different URLs that use the same classes and JSP pages, but reference
two different databases (test and production). Is there a standard way
of achieving this?
Thanks,
Simon
--
Simon (Vsevolod ILyushchenko) simonf@cshl.edu
http://www.simonf.com
Terrorism is a tactic and so to declare war on terrorism
is equivalent to Roosevelt's declaring war on blitzkrieg.
Zbigniew Brzezinski, U.S. national security advisor, 1977-81
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
How to define contexts?
Posted by "Vsevolod (Simon) Ilyushchenko" <si...@cshl.edu>.
Hassan,
> Well, maybe I misunderstood the original question :-)
No, it's just me unfamiliar with the idea of contexts.
So far I've figured out that there is a file context.xml that can define
extra parameters for an application, but I'm not sure about:
1) Whether it's possible to direct two contexts at the same codebase.
I'm looking at Catalina/localhost/manager.xml and host-manager.xml, and
they use different codebases.
2) How to tie a particular context to a particular URL, as you indicate
below. Currently I have dev and www DNS aliases both pointing to virtual
host in apache, and these hosts ProxyPass everything to two different
Tomcat applications (/dev and /pro). Ideally, I'd like to have one
Tomcat application, but I'm not sure how to list two contexts for one
application.
Thanks,
Simon
> My presumption was that the same code exists at, say,
> http://dev.example.com/ and http://www.example.com
> which are clearly different Contexts, even if they're on the same
> machine being run as virtual hosts.
>
> So each Context has a Resource addressing the appropriate DB.
--
Simon (Vsevolod ILyushchenko) simonf@cshl.edu
http://www.simonf.com
Terrorism is a tactic and so to declare war on terrorism
is equivalent to Roosevelt's declaring war on blitzkrieg.
Zbigniew Brzezinski, U.S. national security advisor, 1977-81
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Different JDBC sources?
Posted by Hassan Schroeder <ha...@webtuitive.com>.
Vsevolod (Simon) Ilyushchenko wrote:
>> Presumably these are two different Contexts; put the appropriate
>> Resource in each ${context}.xml file...
> Thanks! How will different contexts be invoked depending on the URL?
Well, maybe I misunderstood the original question :-)
My presumption was that the same code exists at, say,
http://dev.example.com/ and http://www.example.com
which are clearly different Contexts, even if they're on the same
machine being run as virtual hosts.
So each Context has a Resource addressing the appropriate DB.
> Also, I need to distinguish between the test and production environment
> in the code to figure out whether emails should be sent or not. Can I
> detect the current context there?
If your setup is as described above, you could use getServerName();
alternatively, put a Parameter in the Context to turn on/off email
sending.
Apologies if this isn't relevant to your environment, though!
--
Hassan Schroeder ----------------------------- hassan@webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Different JDBC sources?
Posted by "Vsevolod (Simon) Ilyushchenko" <si...@cshl.edu>.
Hassan Schroeder wrote on 09/13/2005 12:33 PM:
> Vsevolod (Simon) Ilyushchenko wrote:
>
>> As a relative Tomcat newbie, I can't find anything about how to use
>> two different JDBC sources with the same codebase. I'd like to have
>> two different URLs that use the same classes and JSP pages, but
>> reference two different databases (test and production). Is there a
>> standard way of achieving this?
>
>
> Presumably these are two different Contexts; put the appropriate
> Resource in each ${context}.xml file...
Hassan,
Thanks! How will different contexts be invoked depending on the URL?
Also, I need to distinguish between the test and production environment
in the code to figure out whether emails should be sent or not. Can I
detect the current context there?
Thanks,
Simon
--
Simon (Vsevolod ILyushchenko) simonf@cshl.edu
http://www.simonf.com
Terrorism is a tactic and so to declare war on terrorism
is equivalent to Roosevelt's declaring war on blitzkrieg.
Zbigniew Brzezinski, U.S. national security advisor, 1977-81
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Different JDBC sources?
Posted by Hassan Schroeder <ha...@webtuitive.com>.
Vsevolod (Simon) Ilyushchenko wrote:
> As a relative Tomcat newbie, I can't find anything about how to use two
> different JDBC sources with the same codebase. I'd like to have two
> different URLs that use the same classes and JSP pages, but reference
> two different databases (test and production). Is there a standard way
> of achieving this?
Presumably these are two different Contexts; put the appropriate
Resource in each ${context}.xml file...
--
Hassan Schroeder ----------------------------- hassan@webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org