Re: reference to the database
Leo Mekenkamp <[email protected]>
| Newsgroups | gmane.comp.java.ozone.user |
|---|---|
| Message-ID | <1079507704.25599.2.camel@mars> |
On Wed, 2004-03-17 at 07:04, Wong Liong Hung wrote:
> How to get the reference to the database in a non-ozone object? As I know
> this can be done in a OzoneObject by invoking database().
>
> I try to use Env.theEnv.database or Env.currentEnv().database, however, I
> got the following exception:-
>
> Exception in thread "main" java.lang.NullPointerException
> at org.ozoneDB.Database.objectForName(Database.java:132)
> at Client.main(Unknown Source)
>
>
> db = new LocalDatabase();
> db.open ("D:/Java/ozone-1.1/db");
> db.reloadClasses();
>
> ....
>
> //in a non-ozone object
> Env.theEnv.database.objectForName( "auto" );
>
> Env.currentEnv().database.objectForName( "auto" );
>
> Note: I'm using ozone version 1.1.
Easiest way is keeping a reference to an OzoneObject from a non-ozone
object. Somewhat more dirty is setting the db object as a static member
of a class.
Cheers,
Leo
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click