IMHO It's better that any db access layer does not know "how" to get a database connection, it just gets given them by the client calling it. This way if you need to change the way you grab db connections the db access layer is none the wiser and no code changes are needed
Jin ----- Original Message ----- From: "Adam Hardy" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, May 29, 2002 5:44 PM Subject: Design Advice - Relational Databases & Java Objects > Hi All, > > I saw this thread in the archives and I thought I'd pinch the title. > I've spent this afternoon surfing the web looking at stuff on Sun, > Jakarta and lots of smaller sites looking for a ready-made data access > layer package but I take it there isn't an open-source one out there. > > Obviously I don't want to tie my data access layer to struts, so there > are a few questions I've got. > > (1) Is it best for the data access layer to throw exceptions on error to > be picked up by the business objects & then struts actions, or would it > be good to use a struts-type message object and use strings in the > application resources file (I'm just worried my exceptions' text would > not be multi-lingual) > > (2) How would I get the database connection info to the data access > layer? Presuming I want to set it up in struts-config.xml or as in > commons-dbcp, would I then pass it in from struts actions into the > business object and then into the data access layer as a parameter on > each call? > > > > I've seen quite a few patterns like www.martinfowler.com and code like > in Sun's Pet Store, so I think I've got a fairly good idea of what I > need. The data access layer I want has got to: > > - take as input and return as output Data Transport Objects > - allow the business objects to control transactions > - use a connection pool > - possibly keep the SQL statements in an external XML file > - have comprehensive error handling & reporting > > > > > -- > 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]>