On Fri, 28 Jan 2005 11:09:41 -0500, Chaikin, Yaakov Y. wrote:
> 1) I hope the code you showed is sitting inside a DAO, not your Action.

Heheh, me too. ;-)

> 2) It looks much messier because you are not using something like a
> ServiceLocator Pattern. Look up and cache the reference to your DataSource
> there. It's cleaner and way faster than doing it every time in your DAO.

For sure!

> 3) Also, to improve performance, you should probably store your connection
> in a private member variable in your DAO and have a base class for your DAO
> with a getConnection() method. This way, any DAOs you implement that extend
> from the BaseDAO will already know how to get the connection in a very
> efficient and clean way.

Hmm, OK, 2 out of 3 is not bad. :-)

I would never reccommend storing a private connection object in a DAO
- that is why we have DataSource objects. Get a connection, use it,
close it, and keep the open time to a minimum. Using a DataSource, you
can open and close connections for almost no cost (in terms of time).
In addition, unit testing that kind of architecture is a major PITA
because of the setup required.

Larry

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

Reply via email to