struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Hall" <dh...@utrs.com>
Subject getDataSource, DAO pattern, and Struts
Date Tue, 12 Sep 2006 01:32:36 GMT
(reposted. Was "DAO and getDataSource" - however that post was made by doing
a reply to another message and simply changing the subject. I didn't realize
that this was thread hijacking. Please accept my apologies, and disregard
the earlier post.)

 

Hopefully this will be a quick question. 

 

I'm using struts 1.2.9 and I need to implement a database connection for my
web application and wanted to use a standard DAO pattern (this is due to the
fact that I will be using connection pooling as well as other datastores to
store application data, and want to decouple the data retrieval
implementation from the business objects as much as possible). I noticed
that struts provides a mechanism for implementing datasource configuration
in the struts-config file and in my online searches I found many examples
that used "getDataSource()" to retrieve the datasource and thereby get a
database connection. However I notice that in the struts documentation it
says: "Ideally, the business logic layer should encapsulate the data access
details, including acquiring a database connection. However, some older
application designs expect that the caller be able to provide a database
connection or DataSource instance. When you need to access a legacy design,
the Struts DataSource manager can make it easy for your Action class to
produce these resources on demand." 

And also - 

"It is preferred that data connectivity be handled directly by the business
classes, usually via JNDI. The Struts DataSource manager should only be used
with legacy business classes that don't provide their own connectivity. When
possible, we strongly recommend use of the standard DAO pattern, so that the
Action classes do not need to know anything about the persitence mechanism.
The DataSource manager is being retained in Struts 1.x for backward
compatibility but may not be retained in Struts 2.x or later."

 

So, should I use the datasource functionality provided in struts, or should
I "roll my own" database connection solution by creating a datasource
factory that can be used to retrieve connections?

 

Thanks,

 

Darren

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message