You might also look at the 'Core J2EE Patterns' book (also now online at sun) 
and look at the 'Service Locator' pattern.  (This assumes the DB is registered 
with a central registry, as it usually is.)  Most of the book's examples are 
about EJB (ugh), but there is a good example there of setting up access to a 
database with good architecture.  They have sample code (example 7.8) which you 
can probably use with almost no modification.  They also have some good advice 
there about separating Data Access code from the rest of your app.

What you need to keep in mind is that these things are not really different in 
Struts than in another programming mode.  Struts only wires thing together for 
you, and the way you design your app and the code you write isn't that much 
dependent on the framework (or at least, it shouldn't be).  So you need to 
learn the framework, but more important, you need to know the fundamentals of 
how to design your app so that it has the least dependence on the framework.  
When you build a house, it shouldn't matter what kind of vacuum cleaner you 
use.  In the same way, when you build an application, it shouldn't matter too 
much what the provider framework is.  The framework just provides services 
which you app can use.  But if that service was not available thru the 
framework, you could get it some other way, and then the *use* of that service 
wouldn't have to change.  Look at Struts as a big bag of nice services you can 
use, and then your app uses those services.  If you went to another service 
provider, not everything would have to change.  If it does, then that is an 
indication that your architecture doesn't properly separate concerns.  Of 
course, all that is 'theory', and implementation always has to make 
compromises.  But it helps to keep it in mind as an ideal.

- Ray Clough



> ----- Original Message -----
> From: "Nuwan Chandrasoma" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <user@struts.apache.org>
> Subject: Re: Spring tutorial
> Date: Mon, 24 Sep 2007 00:16:03 +0530
> 
> 
> Hi,
> 
> you can use the same approach you used in servlets.  if you use 
> spring it will help you write the code in more elegant way :)
> 
> Thanks,
> 
> Nuwan
> 
> rama krishna yalagandula wrote:
> > Yes... Exactly that is the my question....... I am **New** to Struts ....I
> > do not know How to do the "Database Connections" in Struts...When I was
> > working with Servlets... I used JDBC thin driver... So My doubt is What are
> > the availabe things to do "Database Connections" and which one very much
> > easier to get into.... plz help me regarding this...
> >
> > Thanks !
> > Rama Krishna.
> >
> >
> > On 9/22/07, Oleg Mikheev <[EMAIL PROTECTED]> wrote:
> >
> >> Martin Gainty wrote:
> >>
> >>> Im sorry.. what is the question?
> >>>
> >> I think he is asking whether he needs to use Spring
> >> fw to connect to DB several times.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

>



- Ray Clough
[EMAIL PROTECTED]



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

Reply via email to