Oh, great! You have just saved my life. Thanks again!

Ethel

Thomas Mahler wrote:

> Hi Ethel,
>
> Ethel Emmons wrote:
> > Sorry I hit the send button too early:
> >
> > AbstractClass - contains the db open in the constructor:
> > --------------
> > constructor:
> >     protected Implementation odmg = OJB.getInstance();
> >     protected Database db = odmg.newDatabase();
> >     //open database
> >     try   {
> >         db.open("repository.xml", Database.OPEN_READ_WRITE);
> >     }  catch (ODMGException ex)   {
> >         ex.printStackTrace();
> >     }
> > abstract public Iterator listAll();
> > abstract public boolean edit();
> > abstract public boolean delete();
> > ...
> >
> > ConcreteClass - extends AbstractClass
> > ----------------------------------------
> > - calls super() from this class' constructor that performs the db connection.
> > - uses the odmg to create Transactions, etc in the listAll(), edit(), delete()
> > methods.
> >
> > Is there any problem to this setup?
>
> seems OK for me.
>
> > Is it correct to connect everytime (by way
> > of the super() in the concreteclass constructor) listAll(), edit() or delete()
> > methods
> > are called (in separate instances - 1 web page displays all, then another web
> > page edits, etc.)
> >
>
> Yes, that's pretty OK too.
> a db.open() is not expensive and does not use any RDBMS resources.
>
> ODMG transactions do release all used resources on commit() or abort()
>
> SO there should not be any resource problems with your approach.
>
> cheers,
> Thomas
>
> > Thanks in advance.
> >
> >
> >>
> >>Ethel Emmons wrote:
> >>
> >>
> >>>In the ODMG tutorial 2 below, an application class
> >>>
> >>>performs db connect/open and passes
> >>>the odmg instance to the delete, edit, insert etc
> >>>classes.
> >>>In a web app where I have several tables to
> >>>update, insert, etc. where can I put the
> >>>connection?
> >>>Do I need to close the connection? Is the
> >>>connection always on?
> >>>Can I check if odmg and db are null before I
> >>>obtain the instance or open the db?
> >>>
> >>>Thanks,
> >>>Ethel
> >>>
> >>>public Application()
> >>>{
> >>>    // get odmg facade instance
> >>>    Implementation odmg = OJB.getInstance();
> >>>    Database db = odmg.newDatabase();
> >>>    //open database
> >>>    try
> >>>    {
> >>>        db.open("repository.xml",
> >>>Database.OPEN_READ_WRITE);
> >>>    }
> >>>    catch (ODMGException ex)
> >>>    {
> >>>        ex.printStackTrace();
> >>>    }
> >>>
> >>>    useCases = new Vector();
> >>>    useCases.add(new UCListAllProducts(odmg));
> >>>    useCases.add(new UCEnterNewProduct(odmg));
> >>>    useCases.add(new UCDeleteProduct(odmg));
> >>>    useCases.add(new UCQuitApplication(odmg));
> >>>}
> >>>
> >>>  --------------------------------------------------
> >>>--
> >>>To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> >>>For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > --
> > To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> > For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to