db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: Progress on MetaDataManager bug?
Date Wed, 04 Feb 2004 00:12:49 GMT
Hi Gus,

Gus Heck wrote:

> Yes you tested my workaround code. What doesn't work is:
> 
>       MetadataManager mm = MetadataManager.getInstance();
>       ConnectionRepository cRepos = mm.connectionRepository();
>       JdbcConnectionDescriptor descriptor = cRepos.getDescriptor(new 
> PBKey("fdbcon"));
> 
> without doing:
> 
>        descriptor.setUserName("sa");
>        descriptor.setPassWord("");
> 

here you lookup a JdbcConnectionDescriptor. If for the given PBKey 
(jcdAlias="fdbcon", user=null, passwd=null) no matching jcd exists, OJB 
checks the used jcdAlias name "fdbcon" could be found in another jcd. If 
yes, a deep copy of this jcd was made and returned by setting given 
user/passwd (null, null). That's the reason why you have to set user/passwd.
This seems a little bit strange, but allows following "feature"

http://db.apache.org/ojb/faq.html#Many different database user - How do 
they login?

> By contrast when you get a descriptor this way:
> 
>    PersistenceBroker broker = 
> PersistenceBrokerFactory.defaultPersistenceBroker();
>    JdbcConnectionDescriptor descriptor = 
> broker.serviceConnectionManager().getConnectionDescriptor();
> 
> there is no need to set the username or password. The question is, is 
> there a good reason for one way to erase the user name and password and 
> the other way retain it.
> 

here you lookup an existing jcd based on the jdbc-connection-descriptor 
in the repository file (the one declared as 'default-connection').

regards,
Armin

> -Gus
> 
> Armin Waibel wrote:
> 
>> Hi,
>>
>>> Cool. Thanks! That works. That just leaves the question of whether 
>>> the way I was doing it _should_ work. Both methods yield a 
>>> JdbcConnectionDescriptor, but with my method the username and 
>>> password have been stripped. Is this a feature that needs 
>>> doucmentation or a bug?
>>>
>>> My way:
>>>
>>>        MetadataManager mm = MetadataManager.getInstance();
>>>        ConnectionRepository cRepos = mm.connectionRepository();
>>>        JdbcConnectionDescriptor descriptor = cRepos.getDescriptor(new 
>>> PBKey("fdbcon"));
>>
>>
>>
>> I did a test using your code:
>>
>> public void testCon() throws Exception
>>     {
>>         JdbcConnectionDescriptor descriptor = 
>> MetadataManager.getInstance().connectionRepository().getDescriptor(TestHelper.DEF_KEY);

>>
>>         descriptor.setUserName("sa");
>>         descriptor.setPassWord("");
>>         Connection existing;
>>         ConnectionFactory cf = 
>> ConnectionFactoryFactory.getInstance().createConnectionFactory();
>>         existing = cf.lookupConnection(descriptor);
>>     }
>>
>> This test works for me.
>>
>> regards,
>> Armin
>>
>>>
>>>
>>> -Gus
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

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


Mime
View raw message