I did something and I have been wondering if it is right...  So this may 
be a good time.

I have three levels in my model...  They look like

Action (Struts action)
DAO object 
Database object 
Oracle DB


the action will call the DAO object along the lines of getCompanyList() 
or somethig
The DAO then eastablishes a connection to a database and passes it to 
the Database object
The Database object then does all of the SQL work to get the data back.

Is this good or bad?

As is, neither the DAO or the Database knows they are in a web 
application.  The actual Database layer works in JDBC but does not have 
any idea of the kind of JDBC database it is working in, only that it has 
a connection passed to it. 

This could be wrong, if so ... Someone tell me!

Thanks



-----Original Message-----
From: jakarta.rainer [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 4:34 AM
To: struts-user
Subject: Re: Database access design question


I want to accesss the database from a business logic bean that should 
not
emplement *.servelet.* classes.
But how can I then initialize the DataSource?
like: dataSource = servlet.findDataSource(null);

??

Thanks Rainer


> What exactly is your question?
> The samples given with Struts do not necessarily following the best
practices, they are more like proof of concepts than anything else.
>
> Rgs
> Vikram
>
> -----Original Message-----
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 1:45 PM
> To: Struts Users Mailing List
> Subject: Database access design question
>
>
> Hi,
>
> I am using the Struts Database pooling.
> My database connection is realised after the sample in the Struts 
User's
> Guide.
> 
http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> But I think the sample is very contradicting.
> In chapter 2.5 Business Logic Beans is said:
> "For maximum code re-use, business logic beans should be designed and
> implemented so that they do not know they are being executed in a web
> application environment. If you find yourself having to import a
> javax.servlet.* class in your bean, you are tying this business logic 
to
the
> web application environment. "
>
> but chapter 2.6 is Accessing the Database in the sample via a
ActionServlet:
> public ActionForward
>        perform(ActionMapping mapping,
>                ActionForm form,
>                HttpServletRequest request,
>                HttpServletResponse response)
> {
>  javax.sql.DataSource dataSource;
>  java.sql.Connection myConnection;
>
>  try {
>    dataSource = servlet.findDataSource(null);
>    myConnection = dataSource.getConnection();
>
> Now I am pretty confused since I want to implement the Database Access 
in
a
> buiseness logic bean.
>
>
> Thanks for your help!
>
> Rainer
>
>
> --
> 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]>
>
>


--
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]>

Reply via email to