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 denis cardon <ca...@yahoo.com> on 2003/02/23 00:26:15 UTC

modifying programmaticaly the jdbc connection descriptor at runtime

Hi,

I was wondering if it is possible to modify at start
up the jdbc connection information (mainly the url)
written in the xml jdbc configuration descriptor.

Here is my problem : I am right now using a hsqldb db
for local caching in a swing based application. The
fact is that this application must also work
disconnected from the main application server.

In order to place the hsqldb files on the hard drive,
I want to put them in a $HOME sub directory of the
current user. This is a data I can only know of at
runtime.

Note : I would prefer not to have to parse and modify
the xml tree directly before giving it to the 
PersistenceBrokerFactory. Moreover for the time being,
I don't either consider running an in-process JNDI
tree... (hey, it's just client side stuff !)

Thanks a lot,

Denis

=====
=========================
|Denis Cardon, Directeur G�n�ral Tranquil I.T. Systems 
|10 rue du Docteur Bouchard, 49400 Saumur
|Tel: +33(0)2.41.67.56.99
|Web: http://www.tranquil-it-systems.fr
=========================

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

Re: modifying programmaticaly the jdbc connection descriptor at runtime

Posted by denis cardon <ca...@yahoo.com>.
Thanks Thomas!

Your hint was just what I needed. OJB and hsqldb work
quite nicely together and they are the perfect pair
for client side application that need to persist data.
Now the db goes directly into the user HOME directory
:-) I just pasted the piece of code to perform the
trick just below. 

Thanks again

Denis

MetadataManager meta = MetadataManager.getInstance();
String userDir = System.getProperty("user.home");
userDir = userDir + "\\.planning\\db";
			
JdbcConnectionDescriptor descriptor =
meta.connectionRepository().getDescriptor(new
PBKey("default","sa",""));
descriptor.setDbAlias(userDir);
			
PersistenceBroker broker =
PersistenceBrokerFactory.createPersistenceBroker(new
PBKey("default","sa",""));

--- Thomas Mahler <th...@web.de> wrote:
> Hi denis,
> 
> denis cardon wrote:
> > Hi,
> > 
> > I was wondering if it is possible to modify at
> start
> > up the jdbc connection information (mainly the
> url)
> > written in the xml jdbc configuration descriptor.
> 
> Yes, you can modify all metadata programmatically.
> Have a look at the classes in
> org.apache.ojb.broker.metadata 
> MetadataManager, ConnectionRepository,
> JdbcConnectionDescriptor etc.
> 
> cheers,
> Thomas
> 
> > 
> > Here is my problem : I am right now using a hsqldb
> db
> > for local caching in a swing based application.
> The
> > fact is that this application must also work
> > disconnected from the main application server.
> > 
> > In order to place the hsqldb files on the hard
> drive,
> > I want to put them in a $HOME sub directory of the
> > current user. This is a data I can only know of at
> > runtime.
> > 
> > Note : I would prefer not to have to parse and
> modify
> > the xml tree directly before giving it to the 
> > PersistenceBrokerFactory. Moreover for the time
> being,
> > I don't either consider running an in-process JNDI
> > tree... (hey, it's just client side stuff !)
> > 
> > Thanks a lot,
> > 
> > Denis
> > 
> > =====
> > =========================
> > |Denis Cardon, Directeur G�n�ral Tranquil I.T.
> Systems 
> > |10 rue du Docteur Bouchard, 49400 Saumur
> > |Tel: +33(0)2.41.67.56.99
> > |Web: http://www.tranquil-it-systems.fr
> > =========================
> > 
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, more
> > http://taxes.yahoo.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
> 


=====
=========================
|Denis Cardon, Directeur G�n�ral Tranquil I.T. Systems 
|10 rue du Docteur Bouchard, 49400 Saumur
|Tel: +33(0)2.41.67.56.99
|Web: http://www.tranquil-it-systems.fr
=========================

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

Re: modifying programmaticaly the jdbc connection descriptor at runtime

Posted by Thomas Mahler <th...@web.de>.
Hi denis,

denis cardon wrote:
> Hi,
> 
> I was wondering if it is possible to modify at start
> up the jdbc connection information (mainly the url)
> written in the xml jdbc configuration descriptor.

Yes, you can modify all metadata programmatically.
Have a look at the classes in org.apache.ojb.broker.metadata 
MetadataManager, ConnectionRepository, JdbcConnectionDescriptor etc.

cheers,
Thomas

> 
> Here is my problem : I am right now using a hsqldb db
> for local caching in a swing based application. The
> fact is that this application must also work
> disconnected from the main application server.
> 
> In order to place the hsqldb files on the hard drive,
> I want to put them in a $HOME sub directory of the
> current user. This is a data I can only know of at
> runtime.
> 
> Note : I would prefer not to have to parse and modify
> the xml tree directly before giving it to the 
> PersistenceBrokerFactory. Moreover for the time being,
> I don't either consider running an in-process JNDI
> tree... (hey, it's just client side stuff !)
> 
> Thanks a lot,
> 
> Denis
> 
> =====
> =========================
> |Denis Cardon, Directeur Général Tranquil I.T. Systems 
> |10 rue du Docteur Bouchard, 49400 Saumur
> |Tel: +33(0)2.41.67.56.99
> |Web: http://www.tranquil-it-systems.fr
> =========================
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>