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 Tue, 25 Apr 2006 22:36:27 GMT
That might work but I'm not sure.  I think it was added
to support multiple DB schema's and not change JDBC 
connections. In a quick scan of the code, I think I 
saw a couple of places in the SQL building sequence
that would break if DBName didn't have a matching 
Schema, especially with queries using Joins.

So, doing this will require each criteria to be tested
under runtime conditions, since the errors would only
show if the query could not be built properly.

FWIW, using the connections methods should build most
queries correctly because the schema info is all 
associated with the DBName.

> -----Original Message-----
> From: Eustache [mailto:eustache.felenc@idilia.com] 
> Sent: Tuesday, April 25, 2006 3:27 PM
> To: Apache Torque Users List
> Subject: Re: using unknown number of databases having the 
> same "structure"
> 
> 
> And what about simply using ?
> 
> Criteria c = new Criteria();
> c.setDbName("db1");
> List myObjects1 = MyClassPeer.doSelect(c);
> c.setDbName("db2");
> List myObjects2 = MyClassPeer.doSelect(c);
> 
> Greg Monroe wrote:
> 
> >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
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 

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


Mime
View raw message