struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea M" <>
Subject R: Multiple Databases.
Date Fri, 21 May 2004 06:37:14 GMT
I don't use Tomcat personally, but in almost all of the appservers out of
there you find an implementation of javax.sql.DataSource.
What you do usually is to configure your pools in the appserver's
configuration file, where you put all of the coordinates, then you access
them thru JNDI 
e.g.  DataSource myDataSource = new

With Struts I made a simple plugIn that does the necessary JNDI lookup at
startup, and then puts the references to the datasources in servletContext.

I believe Tomcat 4x+ has a JNDI provider too.

-----Messaggio originale-----
Da: Geeta Ramani [] 
Inviato: giovedì 20 maggio 2004 14.52
A: Struts Users Mailing List
Oggetto: RE: Multiple Databases.


If you are using tomcat, then I believe you can use dbcp. (I think that's
what Riyad Kalla was talking about too..) We use dbcp but only for
connecting to one pool (and this turned out to be quite simple: just
configure the server.xml), but I think I read that you can create multiple
pools, which seems to be what you need. (My guess is you add more <Resource
elements in your particular context in the server.xml and give all the db
info in the corresponding ResourceParams.. Like I said, i haven't doene this
with multiple databases, but seems like the machinery is there..

This article contains a link with an example and a "How to tell tomcat to
use dbcp" piece:

And here's a detailed how-to:


> -----Original Message-----
> From: Vishal Arora []
> Sent: Thursday, May 20, 2004 1:22 AM
> To: Struts Users Mailing List
> Subject: Re: Multiple Databases.
> well  that not the problem  but my problem is that i want to 
> connect to
> different databases  in my application and i m using 
> datasource object  and
> in my xml file i have given the details of my database
> url,username,password  etc etc. but now i want to connect to another
> database and if in struts-config.xml i give information abt 
> other database
> .but when in my controller when i will give call to my 
> datasource object to
> which database the connection will be made and how can i handle
> if i want to make connection to Database A and after 
> sometime in
> the same file if i want to make connection to DatabaseB how 
> will it work and
> what all changes i will have to make.and where. Pleaseif 
> anybody can provide
> an example it will be very helpfull.
> Thanks.> 

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message