db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Monroe" <Greg.Mon...@DukeCE.com>
Subject RE: using unknown number of databases having the same "structure"
Date Thu, 20 Apr 2006 17:53:35 GMT
First, a warning about re-initializing Torque on the fly.  
You need to remember that your web application might be
in use by more than one person.  You need to take this 
into account in your code to insure nobody has their
DB setting redone by someone else.

That said, most of Torque's main methods have versions
that take an SQL connection object as a parameter.  If 
you write your code to use these methods, you can use
these methods on any matching DB. 

Note that you will have to do your own management of
these connections, e.g. opening, closing, pooling, 
transaction handling, and the like.

Also not that some of the Torque methods (like getting
foreign key linked records) open connections interally 
using the matching schema dbname JDBC info.  These will 
not work with on the fly DB selection.

One possible thing to look at is using Torque's
getConnection( dbName ) method to let Torque's DBFactory 
manage your connection pool. The main issue here might be
figuring out how to add a new DB on the fly.  Looking at
TorqueInstance.initDataSourceFactories( Configuration ),
it seems like you could override Torque and TorqueInstance
to be able to add DataSourceFactories on the fly.

> -----Original Message-----
> From: Eustache [mailto:eustache.felenc@idilia.com] 
> OK sorry for not being clear:
> It's a single web app that wants to have access to several 
> databases at 
> runtime.
> Roughly: the user can select the database he is going to work 
> on, and he 
> can even use this webapp to add a new database he is going to 
> work on. Those databases have the same structure though. I 
> hope this helps clarify

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential communication
or may otherwise be privileged or confidential and are intended solely for the individual
or entity to whom they are addressed.  If you are not the intended recipient you may not rely
on the contents of this email or any attachments, and we ask that you  please not read, copy
or retransmit this communication, but reply to the sender and destroy the email, its contents,
and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying
of this communication is strictly prohibited.

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message