db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Gordon <rgor...@mwt.net>
Subject Torque with more dynamic DB connections...
Date Mon, 05 Jan 2004 23:29:25 GMT
I have been following thread regarding using a TorqueInstance with
multiple
databases, etc.

I have a similar wish and a proposed solution, if I can get the
eyes/ears of a developer.

I want to be able to use the same tables (ie Peers) across multiple
databases. It just so
happens, for a data collection application, I will have "many" databases
with same
schema. The data collection application will be configured at start-up
with the name of
the db to which it should write data.

Hence, I want my peers to have their DATABASE_NAME set at runtime, not
in
a static final as is currently done.

My proposal/question/wish is that the templates/om/Peer.vm be changed to

include  setDatabaseName()/getDatabaseName() and all the references to
DATABASE_NAME be changed to invoke the appropriate method.

Here is a snippet from Peer.vm

 public static $table.JavaName ${retrieveMethod}(ObjectKey pk)
        throws TorqueException, NoRowsException, TooManyRowsException
    {
        Connection db = null;
        $table.JavaName retVal = null;
        try
        {
 /* here */           db = Torque.getConnection(DATABASE_NAME);
            retVal = ${retrieveMethod}(pk, db);
        }
        finally
        {
            Torque.closeConnection(db);
        }
        return(retVal);
    }

Why couldn't the line I have labelled /* here */ read

    db = Torque.getConnection(getDatabaseName());

with  appropriate accessors methods and instance variable supplied by
Peer.vm???

I am by no means a Torque expert but does this violate any usage idioms?

Thanks
Rob


---------------------------------------------------------------------
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