You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Coup, Robert Muir" <r....@auckland.ac.nz> on 2004/03/26 02:02:23 UTC

Multiple ODMG Databases open concurrently

Hi all,

Situation: 
We use a single data/db model which can either be an online network
database (PGSql) or an offline local one (HSQLDB). At startup time, the
user chooses which to use, and we just apply a different
connection-descriptor. That all works great.

Now one feature requires a connection to the online db and we wanted
this to be made accessible for the offline users if they happen to be
connected. I need to have 2 odmg connections open at the same time for a
short period - is this possible? From a quick look through the OJB &
DatabaseImpl docs it seems that OJB only supports a single open db...

Are there workarounds other than closing and opening each in turn?

Thanks for your help,

Rob :)

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


Re: Multiple ODMG Databases open concurrently

Posted by Armin Waibel <ar...@apache.org>.
Hi Robert,

this is possible. The ...odmg.Implementation implementation class 
odmg.OJB is not a singleton, thus you can obtain two instances of this 
class and open two different databases (e.g. in a startup class).

Implementation ojb_1 = OJB.getInstance();
Database db1 = ojb_1.newDatabase();
...
Implementation ojb_1 = OJB.getInstance();
Database db1 = ojb_1.newDatabase();
...

Now you can use both databases parallel, but keep in mind that OJB does 
not support distributed transactions (span one tx over both DB). To use 
this you have run OJB in a managed enviroment.

A test case using this approach in test suite is called 
...odmg.MultiDBUsageTest.

regards,
Armin

Coup, Robert Muir wrote:
> Hi all,
> 
> Situation: 
> We use a single data/db model which can either be an online network
> database (PGSql) or an offline local one (HSQLDB). At startup time, the
> user chooses which to use, and we just apply a different
> connection-descriptor. That all works great.
> 
> Now one feature requires a connection to the online db and we wanted
> this to be made accessible for the offline users if they happen to be
> connected. I need to have 2 odmg connections open at the same time for a
> short period - is this possible? From a quick look through the OJB &
> DatabaseImpl docs it seems that OJB only supports a single open db...
> 
> Are there workarounds other than closing and opening each in turn?
> 
> Thanks for your help,
> 
> Rob :)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

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