Database Access Layer
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Barney_Boisvert
Posted On:   Wednesday, November 21, 2001 08:52 AM

I'm new both to Struts and JSP/Servlets, although I've been using Java for several years. I'm somewhat perplexed as to how to set up the database access layer in my 'playing around' application. I found the sample app that came with Struts to be very helpful in all respects, except for this one, as the 'database' interactions were inside the Action classes, rather than encapsulated in a database access Bean. According to the accompanying docs (and my intuition), this "should be considered a bug in the example application." I'm wondering what's the best way to build in a database access layer. It seems to me that it should be in an application Bean, encapsulating all the database specific stuff like connection p   More>>

I'm new both to Struts and JSP/Servlets, although I've been using Java for several years. I'm somewhat perplexed as to how to set up the database access layer in my 'playing around' application.

I found the sample app that came with Struts to be very helpful in all respects, except for this one, as the 'database' interactions were inside the Action classes, rather than encapsulated in a database access Bean. According to the accompanying docs (and my intuition), this "should be considered a bug in the example application."

I'm wondering what's the best way to build in a database access layer. It seems to me that it should be in an application Bean, encapsulating all the database specific stuff like connection parameters, and things, but Struts already has it's data-source stuff to do basic connection pooling for it.

As I see it, there isn't really a good way to isolate the database access from the Action classes, because all the data-source stuff done by Struts is internal to the ActionController Servlet, rather than in an application bean, which would make sense to me. At least that's the way I understand things now.

Any help would be appreciated, even if it's an RTFM, assuming you provide a URL for me to look at. I did some searching around last night, to no avail.

   <<Less

Re: Database Access Layer

Posted By:   Ted_Husted  
Posted On:   Wednesday, November 21, 2001 05:44 PM

Follow your instincts, Barney.


Create your database layer separately from the
Actions. Don't use the Struts generic connection pool,
since it is coupled with the Servlet/Web layer. I like
Poolman myself.


There's an Artimus sample application on the
More About Struts
page that does exactly this. It's also available in the Struts nightly build under
the contrib folder.


HTH -Ted

About | Sitemap | Contact