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 Armin Waibel <ar...@code-au-lait.de> on 2003/08/31 02:01:18 UTC

Re: How to specify non-default DataSource for ODMG/PB api in different scenarios?

Hi Alex,

----- Original Message -----
From: "Bates, Alex" <AB...@teradata-ncr.com>
To: "'OJB Users List'" <oj...@db.apache.org>
Sent: Friday, August 29, 2003 10:31 PM
Subject: How to specify non-default DataSource for ODMG/PB api in
different scenarios?


> Hello,
>
> I'm using the ODMG/PB APIs in the following situations; in each I need
to be
> able to tell OJB to use a named DataSource (defined in
> repository_database.xml) other than the default.  Any help would be
> appreciated -
>

do you mean changing the used DataSource within
a transaction or only how to use multiple databases?

regards,
Armin

> --------------
>
>             Transaction tx = odmg.currentTransaction();
>             tx.lock(obj, Transaction.WRITE);
>
> --------------
>
>             db = odmg.getDatabase(null);
>             db.deletePersistent(obj);
>
> --------------
>
>             PersistenceBroker broker = ((HasBroker)
> odmg.currentTransaction()).getBroker();
>             Connection conn = null;
>             try {
>                 conn =
broker.serviceConnectionManager().getConnection();
>             } catch (LookupException e) {
>                 e.printStackTrace();
>             }
>
> --------------
>
>             // Must mark object as dirty to signal OJB to persist
>             Transaction tx = odmg.currentTransaction();
>             ((NarrowTransaction)tx).markDirty(obj);
>
> ---------------
>
>
> Thanks!
>
> Alex
>
>
> ---------------------------------------------------------------------
> 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


Re: How to specify non-default DataSource for ODMG/PB api in different scenarios?

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Alex,

>
> I looked into the relevent OJB source a little, and am curious if this
would
> be a valid solution:
>
> Instead of using
>   Transaction tx = odmg.currentTransaction();
>   tx.lock(obj, Transaction.WRITE);
>
> use
>   Database db = odmg.getDatabase(jcdAlias);
>   db.makePersistent(obj);
>
> would this achieve the same thing?
>
No, odmg.getDatabase always return the current open
database or null.

Why you don't deploy the same bean with different
jndi-names/local names and pass the jcdAlias(/user/passwd
 - if declared in repository.xml you don't need it)
by env-entry tags declared in deployment descriptor?

e.g.
<env-entry>
      <env-entry-name>jcdAlias</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>myDatabase</env-entry-value>
</env-entry>

In ejbCreate method of the session bean do something
like that:

InitialContext ctx = ....
String jcdAlias = lookup("java:comp/env/jcdAlias");
...
...
database.open(jcdAlias, Database.OPEN_READ_WRITE);

regards,
Armin

> Alex
>
> -----Original Message-----
> From: Alex Bates [mailto:abates@san.rr.com]
> Sent: Tuesday, September 02, 2003 1:21 AM
> To: OJB Users List; Armin Waibel
> Subject: RE: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> Armin,
>
> Thanks for the description.  I forgot to mention, I'm using EJBs that
I
> modelled after the OJB sample EJBs.  So, for my ODMG save methods, I'm
using
>
>    Transaction tx = odmg.currentTransaction();
>    tx.lock(obj, Transaction.WRITE);
>
>
> Where odmg is created by a factory in the ejbCreate method as follows;
>
> public class PersistenceManagerBean implements SessionBean
> {
>    private Implementation odmg;
>    private Database db;
>
>    ODMGFactory factory =
> (ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP);
>    odmg = factory.getInstance();
>    db = odmg.newDatabase();
>
>
> Since the currentTransaction method doesn't appear to have any way to
pass
> in a jdcAlias, I'm not sure how to pass it in in my persist methods.
In
> fact, looking closer at the OJB example EJBs, the save methods don't
even
> use the Database db member, they just use
>
>    Transaction tx = odmg.currentTransaction();
>    tx.lock(obj, Transaction.WRITE);
>
>
> How would I specify the jdcAlias in this case?
>
> Thx,
>
> Alex
>
>
> -----Original Message-----
> From: Armin Waibel [mailto:armin@code-au-lait.de]
> Sent: Sunday, August 31, 2003 12:47 AM
> To: OJB Users List
> Subject: Re: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> Hi Alex,
>
> >
> > > do you mean changing the used DataSource within
> > > a transaction or only how to use multiple databases?
> >
> > Only how to use with multiple DataSources (each with a different
> database
> > login and different privelages).  i.e. I've defined multiple
> DataSources in
> > JBoss.
> >
>
> Define for each DataSource a jdbc-connection-descriptor.
>
> PB-api:
> Use the defined jcdAlias name and PBKey to lookup
> the different DataSources
>
> PBKey user_1 = new PBKey(jcdAlias,username, passwd);
> PersistenceBroker broker =
>             PersistenceBrokerFactory.createPersistenceBroker(user_1);
>
> ODMG-api:
> Use jcdAlias name to lookup different DataSources
>
> Implementation odmg = OJB.getInstance();
> Database db = odmg.newDatabase();
> db.open("jcdAlias#username#passwd", Database.OPEN_READ_WRITE);
>
>
> see http://db.apache.org/ojb/faq.html
> (or in shipped docs) sections
> 'How do I use multiple databases within OJB?'
> 'Many different database user - How do they login?'
> 'Needed to put user/password of database connection in repository
file?'
>
> HTH
> regards,
> Armin
>
> > Thanks,
> >
> > Alex
> >
> > -----Original Message-----
> > From: Armin Waibel [mailto:armin@code-au-lait.de]
> > Sent: Saturday, August 30, 2003 5:01 PM
> > To: OJB Users List
> > Subject: Re: How to specify non-default DataSource for ODMG/PB api
in
> > different scenarios?
> >
> >
> > Hi Alex,
> >
> > ----- Original Message -----
> > From: "Bates, Alex" <AB...@teradata-ncr.com>
> > To: "'OJB Users List'" <oj...@db.apache.org>
> > Sent: Friday, August 29, 2003 10:31 PM
> > Subject: How to specify non-default DataSource for ODMG/PB api in
> > different scenarios?
> >
> >
> > > Hello,
> > >
> > > I'm using the ODMG/PB APIs in the following situations; in each I
> need
> > to be
> > > able to tell OJB to use a named DataSource (defined in
> > > repository_database.xml) other than the default.  Any help would
be
> > > appreciated -
> > >
> >
> > do you mean changing the used DataSource within
> > a transaction or only how to use multiple databases?
> >
> > regards,
> > Armin
> >
> > > --------------
> > >
> > >             Transaction tx = odmg.currentTransaction();
> > >             tx.lock(obj, Transaction.WRITE);
> > >
> > > --------------
> > >
> > >             db = odmg.getDatabase(null);
> > >             db.deletePersistent(obj);
> > >
> > > --------------
> > >
> > >             PersistenceBroker broker = ((HasBroker)
> > > odmg.currentTransaction()).getBroker();
> > >             Connection conn = null;
> > >             try {
> > >                 conn =
> > broker.serviceConnectionManager().getConnection();
> > >             } catch (LookupException e) {
> > >                 e.printStackTrace();
> > >             }
> > >
> > > --------------
> > >
> > >             // Must mark object as dirty to signal OJB to persist
> > >             Transaction tx = odmg.currentTransaction();
> > >             ((NarrowTransaction)tx).markDirty(obj);
> > >
> > > ---------------
> > >
> > >
> > > Thanks!
> > >
> > > Alex
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
> ---------------------------------------------------------------------
> > 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
>
>
> ---------------------------------------------------------------------
> 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
>
>
>



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


RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?

Posted by Alex Bates <ab...@san.rr.com>.
I looked into the relevent OJB source a little, and am curious if this would
be a valid solution:

Instead of using
  Transaction tx = odmg.currentTransaction();
  tx.lock(obj, Transaction.WRITE);

use
  Database db = odmg.getDatabase(jcdAlias);
  db.makePersistent(obj);

would this achieve the same thing?

Alex

-----Original Message-----
From: Alex Bates [mailto:abates@san.rr.com]
Sent: Tuesday, September 02, 2003 1:21 AM
To: OJB Users List; Armin Waibel
Subject: RE: How to specify non-default DataSource for ODMG/PB api in
different scenarios?


Armin,

Thanks for the description.  I forgot to mention, I'm using EJBs that I
modelled after the OJB sample EJBs.  So, for my ODMG save methods, I'm using

   Transaction tx = odmg.currentTransaction();
   tx.lock(obj, Transaction.WRITE);


Where odmg is created by a factory in the ejbCreate method as follows;

public class PersistenceManagerBean implements SessionBean
{
   private Implementation odmg;
   private Database db;

   ODMGFactory factory =
(ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP);
   odmg = factory.getInstance();
   db = odmg.newDatabase();


Since the currentTransaction method doesn't appear to have any way to pass
in a jdcAlias, I'm not sure how to pass it in in my persist methods.  In
fact, looking closer at the OJB example EJBs, the save methods don't even
use the Database db member, they just use

   Transaction tx = odmg.currentTransaction();
   tx.lock(obj, Transaction.WRITE);


How would I specify the jdcAlias in this case?

Thx,

Alex


-----Original Message-----
From: Armin Waibel [mailto:armin@code-au-lait.de]
Sent: Sunday, August 31, 2003 12:47 AM
To: OJB Users List
Subject: Re: How to specify non-default DataSource for ODMG/PB api in
different scenarios?


Hi Alex,

>
> > do you mean changing the used DataSource within
> > a transaction or only how to use multiple databases?
>
> Only how to use with multiple DataSources (each with a different
database
> login and different privelages).  i.e. I've defined multiple
DataSources in
> JBoss.
>

Define for each DataSource a jdbc-connection-descriptor.

PB-api:
Use the defined jcdAlias name and PBKey to lookup
the different DataSources

PBKey user_1 = new PBKey(jcdAlias,username, passwd);
PersistenceBroker broker =
            PersistenceBrokerFactory.createPersistenceBroker(user_1);

ODMG-api:
Use jcdAlias name to lookup different DataSources

Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open("jcdAlias#username#passwd", Database.OPEN_READ_WRITE);


see http://db.apache.org/ojb/faq.html
(or in shipped docs) sections
'How do I use multiple databases within OJB?'
'Many different database user - How do they login?'
'Needed to put user/password of database connection in repository file?'

HTH
regards,
Armin

> Thanks,
>
> Alex
>
> -----Original Message-----
> From: Armin Waibel [mailto:armin@code-au-lait.de]
> Sent: Saturday, August 30, 2003 5:01 PM
> To: OJB Users List
> Subject: Re: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> Hi Alex,
>
> ----- Original Message -----
> From: "Bates, Alex" <AB...@teradata-ncr.com>
> To: "'OJB Users List'" <oj...@db.apache.org>
> Sent: Friday, August 29, 2003 10:31 PM
> Subject: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> > Hello,
> >
> > I'm using the ODMG/PB APIs in the following situations; in each I
need
> to be
> > able to tell OJB to use a named DataSource (defined in
> > repository_database.xml) other than the default.  Any help would be
> > appreciated -
> >
>
> do you mean changing the used DataSource within
> a transaction or only how to use multiple databases?
>
> regards,
> Armin
>
> > --------------
> >
> >             Transaction tx = odmg.currentTransaction();
> >             tx.lock(obj, Transaction.WRITE);
> >
> > --------------
> >
> >             db = odmg.getDatabase(null);
> >             db.deletePersistent(obj);
> >
> > --------------
> >
> >             PersistenceBroker broker = ((HasBroker)
> > odmg.currentTransaction()).getBroker();
> >             Connection conn = null;
> >             try {
> >                 conn =
> broker.serviceConnectionManager().getConnection();
> >             } catch (LookupException e) {
> >                 e.printStackTrace();
> >             }
> >
> > --------------
> >
> >             // Must mark object as dirty to signal OJB to persist
> >             Transaction tx = odmg.currentTransaction();
> >             ((NarrowTransaction)tx).markDirty(obj);
> >
> > ---------------
> >
> >
> > Thanks!
> >
> > Alex
> >
> >
>
> ---------------------------------------------------------------------
> > 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
>
>
> ---------------------------------------------------------------------
> 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


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


RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?

Posted by Alex Bates <ab...@san.rr.com>.
Armin,

Thanks for the description.  I forgot to mention, I'm using EJBs that I
modelled after the OJB sample EJBs.  So, for my ODMG save methods, I'm using

   Transaction tx = odmg.currentTransaction();
   tx.lock(obj, Transaction.WRITE);


Where odmg is created by a factory in the ejbCreate method as follows;

public class PersistenceManagerBean implements SessionBean
{
   private Implementation odmg;
   private Database db;

   ODMGFactory factory =
(ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP);
   odmg = factory.getInstance();
   db = odmg.newDatabase();


Since the currentTransaction method doesn't appear to have any way to pass
in a jdcAlias, I'm not sure how to pass it in in my persist methods.  In
fact, looking closer at the OJB example EJBs, the save methods don't even
use the Database db member, they just use

   Transaction tx = odmg.currentTransaction();
   tx.lock(obj, Transaction.WRITE);


How would I specify the jdcAlias in this case?

Thx,

Alex


-----Original Message-----
From: Armin Waibel [mailto:armin@code-au-lait.de]
Sent: Sunday, August 31, 2003 12:47 AM
To: OJB Users List
Subject: Re: How to specify non-default DataSource for ODMG/PB api in
different scenarios?


Hi Alex,

>
> > do you mean changing the used DataSource within
> > a transaction or only how to use multiple databases?
>
> Only how to use with multiple DataSources (each with a different
database
> login and different privelages).  i.e. I've defined multiple
DataSources in
> JBoss.
>

Define for each DataSource a jdbc-connection-descriptor.

PB-api:
Use the defined jcdAlias name and PBKey to lookup
the different DataSources

PBKey user_1 = new PBKey(jcdAlias,username, passwd);
PersistenceBroker broker =
            PersistenceBrokerFactory.createPersistenceBroker(user_1);

ODMG-api:
Use jcdAlias name to lookup different DataSources

Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open("jcdAlias#username#passwd", Database.OPEN_READ_WRITE);


see http://db.apache.org/ojb/faq.html
(or in shipped docs) sections
'How do I use multiple databases within OJB?'
'Many different database user - How do they login?'
'Needed to put user/password of database connection in repository file?'

HTH
regards,
Armin

> Thanks,
>
> Alex
>
> -----Original Message-----
> From: Armin Waibel [mailto:armin@code-au-lait.de]
> Sent: Saturday, August 30, 2003 5:01 PM
> To: OJB Users List
> Subject: Re: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> Hi Alex,
>
> ----- Original Message -----
> From: "Bates, Alex" <AB...@teradata-ncr.com>
> To: "'OJB Users List'" <oj...@db.apache.org>
> Sent: Friday, August 29, 2003 10:31 PM
> Subject: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> > Hello,
> >
> > I'm using the ODMG/PB APIs in the following situations; in each I
need
> to be
> > able to tell OJB to use a named DataSource (defined in
> > repository_database.xml) other than the default.  Any help would be
> > appreciated -
> >
>
> do you mean changing the used DataSource within
> a transaction or only how to use multiple databases?
>
> regards,
> Armin
>
> > --------------
> >
> >             Transaction tx = odmg.currentTransaction();
> >             tx.lock(obj, Transaction.WRITE);
> >
> > --------------
> >
> >             db = odmg.getDatabase(null);
> >             db.deletePersistent(obj);
> >
> > --------------
> >
> >             PersistenceBroker broker = ((HasBroker)
> > odmg.currentTransaction()).getBroker();
> >             Connection conn = null;
> >             try {
> >                 conn =
> broker.serviceConnectionManager().getConnection();
> >             } catch (LookupException e) {
> >                 e.printStackTrace();
> >             }
> >
> > --------------
> >
> >             // Must mark object as dirty to signal OJB to persist
> >             Transaction tx = odmg.currentTransaction();
> >             ((NarrowTransaction)tx).markDirty(obj);
> >
> > ---------------
> >
> >
> > Thanks!
> >
> > Alex
> >
> >
>
> ---------------------------------------------------------------------
> > 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
>
>
> ---------------------------------------------------------------------
> 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


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


Re: How to specify non-default DataSource for ODMG/PB api in different scenarios?

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Alex,

>
> > do you mean changing the used DataSource within
> > a transaction or only how to use multiple databases?
>
> Only how to use with multiple DataSources (each with a different
database
> login and different privelages).  i.e. I've defined multiple
DataSources in
> JBoss.
>

Define for each DataSource a jdbc-connection-descriptor.

PB-api:
Use the defined jcdAlias name and PBKey to lookup
the different DataSources

PBKey user_1 = new PBKey(jcdAlias,username, passwd);
PersistenceBroker broker =
            PersistenceBrokerFactory.createPersistenceBroker(user_1);

ODMG-api:
Use jcdAlias name to lookup different DataSources

Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open("jcdAlias#username#passwd", Database.OPEN_READ_WRITE);


see http://db.apache.org/ojb/faq.html
(or in shipped docs) sections
'How do I use multiple databases within OJB?'
'Many different database user - How do they login?'
'Needed to put user/password of database connection in repository file?'

HTH
regards,
Armin

> Thanks,
>
> Alex
>
> -----Original Message-----
> From: Armin Waibel [mailto:armin@code-au-lait.de]
> Sent: Saturday, August 30, 2003 5:01 PM
> To: OJB Users List
> Subject: Re: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> Hi Alex,
>
> ----- Original Message -----
> From: "Bates, Alex" <AB...@teradata-ncr.com>
> To: "'OJB Users List'" <oj...@db.apache.org>
> Sent: Friday, August 29, 2003 10:31 PM
> Subject: How to specify non-default DataSource for ODMG/PB api in
> different scenarios?
>
>
> > Hello,
> >
> > I'm using the ODMG/PB APIs in the following situations; in each I
need
> to be
> > able to tell OJB to use a named DataSource (defined in
> > repository_database.xml) other than the default.  Any help would be
> > appreciated -
> >
>
> do you mean changing the used DataSource within
> a transaction or only how to use multiple databases?
>
> regards,
> Armin
>
> > --------------
> >
> >             Transaction tx = odmg.currentTransaction();
> >             tx.lock(obj, Transaction.WRITE);
> >
> > --------------
> >
> >             db = odmg.getDatabase(null);
> >             db.deletePersistent(obj);
> >
> > --------------
> >
> >             PersistenceBroker broker = ((HasBroker)
> > odmg.currentTransaction()).getBroker();
> >             Connection conn = null;
> >             try {
> >                 conn =
> broker.serviceConnectionManager().getConnection();
> >             } catch (LookupException e) {
> >                 e.printStackTrace();
> >             }
> >
> > --------------
> >
> >             // Must mark object as dirty to signal OJB to persist
> >             Transaction tx = odmg.currentTransaction();
> >             ((NarrowTransaction)tx).markDirty(obj);
> >
> > ---------------
> >
> >
> > Thanks!
> >
> > Alex
> >
> >
>
> ---------------------------------------------------------------------
> > 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
>
>
> ---------------------------------------------------------------------
> 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


RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?

Posted by Alex Bates <ab...@san.rr.com>.
> do you mean changing the used DataSource within
> a transaction or only how to use multiple databases?

Only how to use with multiple DataSources (each with a different database
login and different privelages).  i.e. I've defined multiple DataSources in
JBoss.

Thanks,

Alex

-----Original Message-----
From: Armin Waibel [mailto:armin@code-au-lait.de]
Sent: Saturday, August 30, 2003 5:01 PM
To: OJB Users List
Subject: Re: How to specify non-default DataSource for ODMG/PB api in
different scenarios?


Hi Alex,

----- Original Message -----
From: "Bates, Alex" <AB...@teradata-ncr.com>
To: "'OJB Users List'" <oj...@db.apache.org>
Sent: Friday, August 29, 2003 10:31 PM
Subject: How to specify non-default DataSource for ODMG/PB api in
different scenarios?


> Hello,
>
> I'm using the ODMG/PB APIs in the following situations; in each I need
to be
> able to tell OJB to use a named DataSource (defined in
> repository_database.xml) other than the default.  Any help would be
> appreciated -
>

do you mean changing the used DataSource within
a transaction or only how to use multiple databases?

regards,
Armin

> --------------
>
>             Transaction tx = odmg.currentTransaction();
>             tx.lock(obj, Transaction.WRITE);
>
> --------------
>
>             db = odmg.getDatabase(null);
>             db.deletePersistent(obj);
>
> --------------
>
>             PersistenceBroker broker = ((HasBroker)
> odmg.currentTransaction()).getBroker();
>             Connection conn = null;
>             try {
>                 conn =
broker.serviceConnectionManager().getConnection();
>             } catch (LookupException e) {
>                 e.printStackTrace();
>             }
>
> --------------
>
>             // Must mark object as dirty to signal OJB to persist
>             Transaction tx = odmg.currentTransaction();
>             ((NarrowTransaction)tx).markDirty(obj);
>
> ---------------
>
>
> Thanks!
>
> Alex
>
>
> ---------------------------------------------------------------------
> 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


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