Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 44928 invoked from network); 2 Jan 2004 14:32:22 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Jan 2004 14:32:22 -0000 Received: (qmail 53470 invoked by uid 500); 2 Jan 2004 14:32:16 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 53462 invoked by uid 500); 2 Jan 2004 14:32:16 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 1376 invoked from network); 2 Jan 2004 04:12:07 -0000 X-Originating-IP: [64.63.227.66] X-Originating-Email: [chinajoeblack@hotmail.com] X-Sender: chinajoeblack@hotmail.com From: "Jiaqi Guo" To: "'Apache Torque Users List'" Subject: RE: Torque with more dynamic DB connections, avoiding singleton and statics? Date: Thu, 1 Jan 2004 22:12:14 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: Thread-Index: AcPPk5+FqLkDnypFTimQPXHouVXOvgBUS7yg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: X-OriginalArrivalTime: 02 Jan 2004 04:12:17.0500 (UTC) FILETIME=[9C02F1C0:01C3D0E6] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Ekkehard, To my understanding, torque is able to connect many databases at the same time without avoiding singleton and static. First it's possible to define more than one database connection for torque like this: Torque.database.default=dsf1 Torque.dsfactory.dsf1.factory=.. ..... Torque.database.another=dsf2 Torque.dsfactory.dsf2.factory=.. ..... At runtime you can call it dynamically: Connection dbcon1 = Torque.getConnection(); //Get a connection for default database Connection dbcon2 = Torque.getConnection("another"); Regards Jiaqi Guo email: g-cyclops@users.sourceforge.net site: http://cyclops-group.sourceforge.net -----Original Message----- From: Ekkehard Kraemer [mailto:ekraemer@pluto.camelot.de] Sent: Wednesday, December 31, 2003 5:48 AM To: torque-user@db.apache.org Subject: Torque with more dynamic DB connections, avoiding singleton and statics? Hello, is it possible to avoid the Torque singleton and static OM members altogether? I have some quite dynamic needs for my DBMS connections. In the easiest case, it boils down to being able to specify which of several databases (defined in the standard Torque property file) to use during runtime. Ideally, I would do something like for (Iterator i=SomePeer.doSelect(whichDb,crit).iterator(); i.hasNext(); ) { Some some=(Some)(i.next()); // some is from whichDb doSomething(some); } Or TorqueInstance torq=new TorqueInstance(whichDb); for (Iterator i=SomePeer.doSelect(torq,crit).iterator(); i.hasNext(); ) ... Or SomePeer somePeer=new SomePeer(whichDb); for (Iterator i=somePeer.doSelect(torq,crit).iterator(); i.hasNext(); ) ... Where whichDb tells Torque which database should be used. While a TorqueInstance exists already, the generated OM classes contain static members for the database name (and maybe other things). I see no place to put the "whichDb" in. Any hint on whether this can be solved, and how? I didn't find much in the documentation or the archives; and looking at the source code made me suspect it is not possible at the moment. Am I wrong? Is this functionality being planned for the future of Torque? Simply changing the "final static" members to "static" and overwriting them as needed is probably not a solution for me, as the next step would be to work on two different databases at the same time (with the same set of OM classes)... Thanks in advance, Ekkehard --------------------------------------------------------------------- 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