Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 53632 invoked from network); 9 Feb 2011 09:50:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Feb 2011 09:50:43 -0000 Received: (qmail 71313 invoked by uid 500); 9 Feb 2011 09:50:39 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 70817 invoked by uid 500); 9 Feb 2011 09:50:35 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 70804 invoked by uid 99); 9 Feb 2011 09:50:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 09:50:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [213.131.255.80] (HELO ks101.cryonhost.eu) (213.131.255.80) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 09:50:25 +0000 Received: from [192.168.1.194] (axivion1.tz.uni-stuttgart.de [129.69.226.21]) (Authenticated sender: web39p11) by ks101.cryonhost.eu (Postfix) with ESMTPSA id A602A6E0F82 for ; Wed, 9 Feb 2011 10:48:41 +0100 (CET) Message-ID: <4D526331.7010702@axivion.com> Date: Wed, 09 Feb 2011 10:49:37 +0100 From: Stephan Beutel User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Context.xml for multiple datasources References: <4D525B8B.5080900@axivion.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Am 09.02.2011 10:30, schrieb chris derham: >> I need some help creating my context.xml file in a correct way. >> >> My application is based on Spring and Hibernate. I need to configure more >> than one datasource >> to access multiple databases at the same time. >> >> > We use JNDI to set up our datasource. So in spring configuration, we have > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > Then in\conf\context.xml we have > > > auth="Container" > type="javax.sql.DataSource" > username="" > password="" > driverClassName="oracle.jdbc.OracleDriver" > url="jdbc:oracle:thin:@localhost:1521:xe" > maxActive="20" > maxIdle="2" > minIdle="1" > initialSize="2" > /> > > > This will provide the jndi data source to all apps in the tomcat instance. > If you wish/need to restrict that to a single war, place the above entry in > conf/Catalina/[host]/[appName].xml. Using this technique you should be able > to specify multiple datasources. > > Chris > Hello, thank you for the quick answer. I know how to configure one datasource and lookup with JNDI. This is my actual configuration. But I need to configure more than one datasource to switch the database at runtime. With my Spring configured datasource it works to access all databases. But I don't know how to create a context for Tomcat to access all databases. ------------------ My configuration to access ONE database: datasource.xml for Spring: ######### org.sqlite.JDBC jdbc:sqlite:C:\firstDatabase.db SA ######### The same datasource as context to lookup with JNDI: ######### ... ... ######### Lookup in Spring: ------------------------------------ The configuration I need in my application: datasource.xml for Spring: ######## ######## And the question is: How to build the context to move the existing Spring configuration to the Tomcat context to get all datasources with JNDI. The problem is, that it must be possible to set a variable amount of databases. I can't set the number of databases to a fixed amount. Building the Resources for the beans named parentDataSource, firstDataSource and secondDataSource is like configuring a single database. But How can I create a JNDI lookable resource like the bean named dataSource containing a map of all available database resources? Regards Stephan --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org