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 henrydav <he...@indiana.edu> on 2009/04/02 16:37:49 UTC

Adding a second data source.

I'm currently working with a project that uses a single data source, using
default-connection=true in the jdbc-connection-descriptor. I now need to add
a second data source, but can I leave the first data source as a
default-connection, or do I need to change it and configure the connection
programmatically? I'm fairly new to this and I've been reading OJB
documentation the past couple of days, but I apologize if I'm leaving out
requisite information.
-- 
View this message in context: http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22849428.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.


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


RE: Adding a second data source.

Posted by Andrei Harangus <an...@travelmaster.com>.
You can leave the first one default and get the second one programmatically.

-----Original Message-----
From: henrydav [mailto:henrydav@indiana.edu] 
Sent: Thursday, April 02, 2009 5:38 PM
To: ojb-user@db.apache.org
Subject: Adding a second data source.


I'm currently working with a project that uses a single data source, using
default-connection=true in the jdbc-connection-descriptor. I now need to add
a second data source, but can I leave the first data source as a
default-connection, or do I need to change it and configure the connection
programmatically? I'm fairly new to this and I've been reading OJB
documentation the past couple of days, but I apologize if I'm leaving out
requisite information.
-- 
View this message in context:
http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22849428.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive
at Nabble.com.


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


AW: AW: Adding a second data source.

Posted by Bernd Längerich <b....@acceptis.com>.
Hi,

in my case, I have two connection descriptors:

	<jdbc-connection-descriptor
      jcd-alias="default"
	default-connection="true"
	...

and 

	<jdbc-connection-descriptor
      jcd-alias="remote"
	default-connection="false"
	...

Using 

      localbroker  = PersistenceBrokerFactory.defaultPersistenceBroker();
      remotebroker = PersistenceBrokerFactory.createPersistenceBroker(new PBKey("remote"));

I can access both data bases.

Best regards
Bernd

-----Ursprüngliche Nachricht-----
Von: henrydav [mailto:henrydav@indiana.edu] 
Gesendet: Donnerstag, 2. April 2009 17:33
An: ojb-user@db.apache.org
Betreff: Re: AW: Adding a second data source.


Okay, both responses verify what I thought was true, so thank you for that.
I've tried the approach you mentioned below
(PersistenceBrokerFactory.createPersistenceBroker(new PBKey("myJcdAlias"))),
as well as the Spring approach (since this project also mixes Spring 1.2
in):

setJcdAlias("myJcdAlias");
getPersistenceBrokerTemplate();

In both cases, my dataSource is null, which leads me to believe my jcd-alias
isn't mapped up properly in the jdbc-connection-descriptor. I guess what I
don't understand is how the jcd-alias value is resolved. To what does this
attribute directly refer or map?

Thanks for your help, Bernd and Andrei.


Bernd Längerich wrote:
> 
> Hi,
> 
> You can leave your existing connection as default and add a second (named)
> connection. You have to specify where to use the second connection by
> using an appropriate method (i.e. for the PB-API
> PersistenceBrokerFactory.createPersistenceBroker(new PBKey(jcdalias)) vs.
> PersistenceBrokerFactory.defaultPersistenceBroker()).
> 
> Best regards 
> Bernd
> 
> -----Ursprüngliche Nachricht-----
> Von: henrydav [mailto:henrydav@indiana.edu] 
> Gesendet: Donnerstag, 2. April 2009 16:38
> An: ojb-user@db.apache.org
> Betreff: Adding a second data source.
> 
> 
> I'm currently working with a project that uses a single data source, using
> default-connection=true in the jdbc-connection-descriptor. I now need to
> add
> a second data source, but can I leave the first data source as a
> default-connection, or do I need to change it and configure the connection
> programmatically? I'm fairly new to this and I've been reading OJB
> documentation the past couple of days, but I apologize if I'm leaving out
> requisite information.
> -- 
> View this message in context:
> http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22849428.html
> Sent from the Apache DB - ObjectRelationalBridge Users mailing list
> archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22850281.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.


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


Re: AW: Adding a second data source.

Posted by henrydav <he...@indiana.edu>.
Okay, both responses verify what I thought was true, so thank you for that.
I've tried the approach you mentioned below
(PersistenceBrokerFactory.createPersistenceBroker(new PBKey("myJcdAlias"))),
as well as the Spring approach (since this project also mixes Spring 1.2
in):

setJcdAlias("myJcdAlias");
getPersistenceBrokerTemplate();

In both cases, my dataSource is null, which leads me to believe my jcd-alias
isn't mapped up properly in the jdbc-connection-descriptor. I guess what I
don't understand is how the jcd-alias value is resolved. To what does this
attribute directly refer or map?

Thanks for your help, Bernd and Andrei.


Bernd Längerich wrote:
> 
> Hi,
> 
> You can leave your existing connection as default and add a second (named)
> connection. You have to specify where to use the second connection by
> using an appropriate method (i.e. for the PB-API
> PersistenceBrokerFactory.createPersistenceBroker(new PBKey(jcdalias)) vs.
> PersistenceBrokerFactory.defaultPersistenceBroker()).
> 
> Best regards 
> Bernd
> 
> -----Ursprüngliche Nachricht-----
> Von: henrydav [mailto:henrydav@indiana.edu] 
> Gesendet: Donnerstag, 2. April 2009 16:38
> An: ojb-user@db.apache.org
> Betreff: Adding a second data source.
> 
> 
> I'm currently working with a project that uses a single data source, using
> default-connection=true in the jdbc-connection-descriptor. I now need to
> add
> a second data source, but can I leave the first data source as a
> default-connection, or do I need to change it and configure the connection
> programmatically? I'm fairly new to this and I've been reading OJB
> documentation the past couple of days, but I apologize if I'm leaving out
> requisite information.
> -- 
> View this message in context:
> http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22849428.html
> Sent from the Apache DB - ObjectRelationalBridge Users mailing list
> archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22850281.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.


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


AW: Adding a second data source.

Posted by Bernd Längerich <b....@acceptis.com>.
Hi,

You can leave your existing connection as default and add a second (named) connection. You have to specify where to use the second connection by using an appropriate method (i.e. for the PB-API PersistenceBrokerFactory.createPersistenceBroker(new PBKey(jcdalias)) vs. PersistenceBrokerFactory.defaultPersistenceBroker()).

Best regards 
Bernd

-----Ursprüngliche Nachricht-----
Von: henrydav [mailto:henrydav@indiana.edu] 
Gesendet: Donnerstag, 2. April 2009 16:38
An: ojb-user@db.apache.org
Betreff: Adding a second data source.


I'm currently working with a project that uses a single data source, using
default-connection=true in the jdbc-connection-descriptor. I now need to add
a second data source, but can I leave the first data source as a
default-connection, or do I need to change it and configure the connection
programmatically? I'm fairly new to this and I've been reading OJB
documentation the past couple of days, but I apologize if I'm leaving out
requisite information.
-- 
View this message in context: http://www.nabble.com/Adding-a-second-data-source.-tp22849428p22849428.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.


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