Re: My object disappear when I restart ozone.

"Dr Brendan Gowing" <[email protected]>
Newsgroups gmane.comp.java.ozone.user
Message-ID <[email protected]>
You're creating a new object on *ANY* exception??!!? That is probably
*really* dangerous and not what you want to do. Rewrite your code to check
for a null obj instead and test again.

-BG



> Hi
>
> I really need your help. my program working very well if I did not
> shutdown it. I can create insert delete. I can restart my application
> and reconnect to my database but when I restart ozone my database will
> disappear. I can't get object from "db.objectForName(ObjName);". It
> return null.
>
> this is my init and main method
>
>
>      public void init(OzoneInterface database){
>          db = database;
>
>          String name = MetCollectionImpl.class.getName();
>
>          Object obj = null;
>
>          try{
>            System.out.println("looking Object name "+ObjName+" from db");
>            obj = db.objectForName(ObjName);
>            metc = (MetCollection)obj;
>            System.out.println("get "+metc.getName()+" read ");
> testRead();
>            testReadComplicate();          testDelete();
>
>          }catch(Exception e){
>            try { //Create new DB
>                System.out.println("can't looking for object because:
> "+e);
>                obj = db.createObject(name, 0,ObjName);
>                System.out.println("create obj name:"+ obj);
>
>                metc = (MetCollection) obj;
>
>                metc.setName("OzoneMetBroker2");
>                System.out.println("ObjectDB name: "+metc.getName()+" was
> created by me");
>
>                testCreate();
>            } catch(Exception e2) {
>                System.out.println("Can't create DB: "+ e2);
>            }
>          }
>      }
>
> public static void main(String[] args) throws Exception{
>
>        System.out.println("Start Local");
>
>        String dbDir = "/java/testozone/ozon";
>        System.out.println("Opening database at "+ dbDir);
>        LocalDatabase database = new LocalDatabase();      if
> (!database.exists(dbDir)){
>             database.create(dbDir);
>        }
>        database.open(dbDir, OzoneDebugLevel.ERROR_STR);
>
>        database.reloadClasses();
>        System.out.println("connect to ozone complete: "+database);
>
>        MetTest msi = new MetTest();
>        msi.init(database);
>        System.out.println("end test");
>      }
>
>
>
>
> please give me some suggestion or some comment what should be wrong in
> my code.
> Thank you very much.
>
> Apirak Panatkool
>
> e-mail [email protected]
> phone 01-4033320



-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.