db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Van Couvering <David.Vancouver...@Sun.COM>
Subject Re: Modifying database properties from Code
Date Sat, 19 Aug 2006 17:19:12 GMT
Glad you were able to figure this out, good work!

David

Sanket Sharma wrote:
> Oh well, I figured out. Assuming the database is represented by db
> i.e. db is of type BasicDatabase.
> 
> String name = Monitor.getMonitor().getServiceName(db);
> PersistentService ps = Monitor.getMonitor().getServiceType(db);
> String fullName = ps.getCanonicalServiceName(name);
> Properties prop = ps.getServiceProperties(fullName, (Properties)null);
> 
> and you have it!
> 
> Best Regards,
> Sanket Sharma
> 
> On 8/17/06, Sanket Sharma <sanketsharma@gmail.com> wrote:
>> Hi
>>
>>
>> Can any one please help me out with a little issue?
>>
>> What is the precise way of accessing a database's properties through
>> the code given a reference to a BasicDatabase Object?
>>
>> I thought the following will do :
>>
>> AccessFactory af = (AccessFactory)Monitor.findServiceModule(basicdb,
>> AccessFactory.MODULE);
>>
>> if( af!=null) {
>>       ContextService cs = ContextService.getFactory();
>> }
>> if(cs!=null){
>>              ContextManager cm = cs.getCurrentContextManager();
>> }
>> if(cm!=null){
>>       TransactionController tc = af.getTransaction(cm);
>> }
>> if(tc!=null){
>>       Properties dbProperties = tc.getProperties();
>>       tc.commit();
>>       tc.destroy();
>>       return (dbProperties.getProperty(attributeName));
>> }
>>
>> However, the call to getCurrentContextManager returns a null value.
>>
>> I've written this code inside my MBean Class. My guess is that this
>> code needs to be in the same "context" as the Database object. How do
>> I ensure that? Am I missing something?
>>
>> Again, while updating the values using TransactionController's
>> methods, I face the same problem.
>>
>> Can anyone please guide?
>>
>> Best Regards,
>> Sanket
>>

Mime
View raw message