db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Barre <Guillaume.Ba...@technomedia.ca>
Subject RE: access multiple data sources from single app using torque?
Date Tue, 01 Apr 2003 20:54:34 GMT
Hi,

I have used the "torque.properties" files below to connect an application
with two differents databases (test1 and test2).
I use defaultIdMethod="idbroker" and my problem is that Torque seems to use
the same "id_table" for the two databases.

Before testing in both test1 and test2 database I have this row in
"id_table" :

| ID_TABLE_ID | TABLE_NAME | NEXT_ID | QUANTITY |
+-------------+------------+---------+----------+
|         101 | users      |    1000 |       10 |

My test is : 

	Connection con1 = Torque.getConnection("test1");
	Users u1 = new Users();
	u1.setNom("U1N");
	u1.setPrenom("U1P");
	u1.save(con1);
	
	Connection con2 = Torque.getConnection("test2");
	Users u2 = new Users();
	u2.setNom("U2N");
	u2.setPrenom("U2P");
	u2.save(con2);

After this in "test1" i have my user "U1P" with the id 1000, in "test2" i
have the user "U2P" with the id 1001, in in the id_table of "test2" i ahve
always 
|         101 | users      |    1000 |       10 | 

but now in id_table from "test1" i have
|         101 | users      |    1010 |       10 |.


I realy think I'm wrong ? I imagine that one database must use this own
"id_table", No ?

Guillaume


-----Original Message-----
From: Jon King [mailto:jon@minaret.com]
Sent: Monday, March 24, 2003 4:34 PM
To: Turbine Torque Users List
Subject: Re: access multiple data sources from single app using torque?


Thanks!  This is really helpful.

Age Mooy wrote:

> Hmmm... as usual my attachment (< 4k) was killed by the list :(
> You'll have to work with the list-garbled raw data then... here it is:
>
> Age
>
> # -------------------------------------------------------------------
> #
> #  T O R Q U E  P R O P E R T I E S
> #
> # -------------------------------------------------------------------
> # This is the configuration file for Torque.
> #
> # Note that strings containing "," (comma) characters must backslash
> # escape the comma (i.e. '\,')
> #
> # These are your database settings. Look in the
> # org.apache.torque.pool.* packages for more information.
> #
> # The parameters to connect to the default database.  You MUST
> # configure these properly.
> # -------------------------------------------------------------------
>
> torque.applicationRoot = .
>
> # -------------------------------------------------------------------
> # Databases
> # -------------------------------------------------------------------
>
> torque.database.default = default
>
> # -------------------------------------------------------------------
> # Database Pools
> # -------------------------------------------------------------------
>
> torque.dsfactory.default.factory =
> org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
> torque.dsfactory.default.pool.defaultMaxActive = 10
> torque.dsfactory.default.pool.testOnBorrow = true
> torque.dsfactory.default.pool.validationQuery = SELECT 1
>
> torque.dsfactory.security.factory =
> org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
> torque.dsfactory.security.pool.defaultMaxActive = 10
> torque.dsfactory.security.pool.testOnBorrow = true
> torque.dsfactory.security.pool.validationQuery = SELECT 1
>
> # -------------------------------------------------------------------
> # Data Sources
> # -------------------------------------------------------------------
>
> torque.database.default.adapter = mysql
> torque.dsfactory.default.connection.driver = org.gjt.mm.mysql.Driver
> torque.dsfactory.default.connection.url =
> jdbc:mysql://localhost:3306/myapp
> torque.dsfactory.default.connection.user = myapp
> torque.dsfactory.default.connection.password = myapp
>
> torque.database.security.adapter = mysql
> torque.dsfactory.security.connection.driver = org.gjt.mm.mysql.Driver
> torque.dsfactory.security.connection.url =
> jdbc:mysql://localhost:3306/security
> torque.dsfactory.security.connection.user = security
> torque.dsfactory.security.connection.password = security
>
> # -------------------------------------------------------------------
> # Misc Properties
> # -------------------------------------------------------------------
>
> # Determines if the quantity column of the IDBroker's id_table should
> # be increased automatically if requests for ids reaches a high
> # volume.
>
> torque.idbroker.cleverquantity = true
>
> # Determines whether the managers cache instances of the business
> objects.
> # And also whether the MethodResultCache will really cache results.
>
> torque.manager.useCache = false
>
> > See the attached Torque.properties file. It has two
> > datasources configured, both with a datasource factory, an
> > adapter, a pool, and a connection. In your schema you can use
> > the database name attribute to specify to which datasource
> > that database belongs.
> >
> > I have one schema for my security database, and a couple of
> > other schemas that use the default database.
> >
> > Age
> >
> > > -----Original Message-----
> > > From: Jon King [mailto:jon@minaret.com]
> > > Sent: Friday, March 21, 2003 19:57
> > > To: torque-user@db.apache.org
> > > Subject: access multiple data sources from single app using torque?
> > >
> > >
> > > I'm like to be able to generate 2 separate object models
> > > (from two different relation data sources) and then access
> > > both object models from a single application.  Is this
> > > possible with torque?  At first blush, it seems that multiple
> > > data sources can't be configured in Torque.properties.  Thanks.
> > >
> > > Jon King
> > > jon@minaret.com
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > 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


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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message