Firstly, making us of the connection pool is ideal.

Use the DAO pattern with the interface, initialize() dao_fn_1(),
dao_fn_2(), ... and close().
Connect in initialize() and disconnect in close().
Doing this the system is modular. DAO is doing its job and the EJB (or
any Business Bean) is getting the job done by the DAO.

Please revert with comments.

--Shashi.

-----Original Message-----
From: Christian Pich [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 09, 2002 11:54 PM
To: [EMAIL PROTECTED]
Subject: How to handle Connection object from ActionServlet


I am wondering how you best architect the flow of the connection object:
It is suggested in Struts to obtain a Connection object in the
ActionServlet
and that is the place where you close or free up the connection after 
the request.
But how do you pass that object down to your middletier where you have 
the views.
 From the Action Servlet I am calling my business classes (beans), e.g. 
create user.
In that class then you call the class where you actually create the sql 
(views, inserts etc.)
or the PreparedStatement. Where would you call the connection and do the

execute?
To pass the connection object into the bean you have to do that in the 
constructor
or set it with a set-method. Which then means you have to do that every 
time you
call a business object separately from the Action class. It feels like 
in the business layer
I do not want to care about the connection. Is there a more elegant  
way to do this.



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


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

Reply via email to