On Wed, 21 Aug 2002, Christian J. Dechery wrote:

> Date: Wed, 21 Aug 2002 16:56:05 -0300
> From: Christian J. Dechery <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: problems with Connections
>
> That's exactly the problem... we dont't have any servlets (I wish we had, but I 
>didn't design, I only code)... only JSPs and classes...
>
> I'll give u an example of how are things here... let's say we have a class called 
>BusinessObject, and a class called DAOBusinessObject...
>
> so I'd have a JSP like that
>
> <%
>     BusinessObject bo = new BusinessObject(); // at this point, DAOBusinessObject 
>requested a connection
>     bo.method1(); // this method calls a method in DAO which runs a query
>     bo.method2(); // this on too... and every other method as well...
> %>
>  so, as long as the DAOBusinessObject object "lives" the Connection is
> there... how am I supposed to close it, since every query needs it? Now
> I see, I should have a method to close the used conn or something... but
> we have up to 50 DAO* classes and more then 200 JSPs...
>
> I agree with what u said about the finalize()... but what should I do then?
>

Give up and start over.

Seriously.

This application design is totally hopeless from a scalability or
reliability viewpoint, because it requires a connection for every business
object, on every page that uses that BO class.  To say nothing of the fact
that JDBC drivers are not required to be thread safe, so you're
undoubtedly causing yourself tremendous grief when the same page is
accessed by more than one user.

If you follow my advice, please follow one other piece -- get a book on
design patterns ("Core J2EE Design Patterns" by Alur/Crupi/Malks is one of
my most well-thumbed resources) and follow the prescribed patterns for
doing this right.

>
> .:| Christian J. Dechery
> .:| FINEP - Depto. de Sistemas
> .:| [EMAIL PROTECTED]
> .:| (21) 2555-0332
>

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to