RE: Database access design question

2002-06-10 Thread wbchmura


I have that now I think...  I get the connection and pass that to the 
program that does not have any ties to the servlets...

the olsource object does not have any knowledge of the fact its a web 
app.  I could drop the same code into a java gui and as long as I passed 
the connection it should run

(Of course I dont know what I am doing either)

Bill


public HashMap getGroupList (org.apache.struts.action.ActionServlet 
servlet, int companyId) {
java.util.HashMap list = new java.util.HashMap();
javax.sql.DataSource dataSource = null;

try {
dataSource = 
(DataSource)servlet.getServletContext().getAttribute("Oracle");
list = olsource.getGroupList(dataSource, companyId); 
  

} catch (Exception e) {
System.out.println ("Connection.process" + e);
e.printStackTrace();
}
return (list);
}




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


Sorry but I am in another galaxy as you guys are. My problems are not 
that
complex yet and my knowledge isn't either.
I would only like to have a simple sample how I can access the Database
defined in the struts-config.xml without having to use any servlet 
depending
methodes/classes  like pageContext, sessions or what so ever. There must 
be
a way!

thanks 1000 times for a hint!

Rainer

- Original Message -
From: "Jerry Jalenak" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Monday, June 10, 2002 3:17 PM
Subject: RE: Database access design question


> I'm needing to move my data access from my Actions to a 'pure' 
business
> bean.  Does anyone have a good example (or link) on how to create and 
use
> DAO?
>
> Thanks.
>
> Jerry
>
> -Original Message-
> From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 3:43 AM
> To: Struts Users Mailing List
> Subject: RE: Database access design question
>
>
> 1. Do not use the session bean to access the datasource... create a 
data
> access object which locates the datasource.
> 2. Lookup the datasource using a jndi name not a servlet. Register 
your
> datasource with the jndi server. (Does the servlet api implement such 
a
> method ??)
> 3. If using a connection pool (which you should really), get the
connection
> object out of the pool and use it to access the database.
>
> HTH
> Vikram
>
>
> -Original Message-
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 2:04 PM
> To: Struts Users Mailing List
> 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();
&

Re: Database access design question

2002-06-10 Thread Ted Husted

You can't access the generic datasource pool defined by the Struts
config from the business tier. The closest you can come is to pass up
the connection. The Struts generic datasource is really * not * the best
way to go for most applications. I do not recommend using it for
production applications. 

Many DBMS packages and containers provide their own connection pools,
including Tomcat 4 I believe. 

My best general recommendation is to grab Poolman 1.4 from 

http://sourceforge.net/project/showfiles.php?group_id=4899

and see:

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg25554.html


-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


rainer juenger wrote:
> 
> Sorry but I am in another galaxy as you guys are. My problems are not that
> complex yet and my knowledge isn't either.
> I would only like to have a simple sample how I can access the Database
> defined in the struts-config.xml without having to use any servlet depending
> methodes/classes  like pageContext, sessions or what so ever. There must be
> a way!
> 
> thanks 1000 times for a hint!
> 
> Rainer
> 
> - Original Message -
> From: "Jerry Jalenak" <[EMAIL PROTECTED]>
> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> Sent: Monday, June 10, 2002 3:17 PM
> Subject: RE: Database access design question
> 
> > I'm needing to move my data access from my Actions to a 'pure' business
> > bean.  Does anyone have a good example (or link) on how to create and use
> > DAO?
> >
> > Thanks.
> >
> > Jerry
> >
> > -----Original Message-
> > From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 3:43 AM
> > To: Struts Users Mailing List
> > Subject: RE: Database access design question
> >
> >
> > 1. Do not use the session bean to access the datasource... create a data
> > access object which locates the datasource.
> > 2. Lookup the datasource using a jndi name not a servlet. Register your
> > datasource with the jndi server. (Does the servlet api implement such a
> > method ??)
> > 3. If using a connection pool (which you should really), get the
> connection
> > object out of the pool and use it to access the database.
> >
> > HTH
> > Vikram
> >
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 2:04 PM
> > To: Struts Users Mailing List
> > 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]>




Re: Database access design question

2002-06-10 Thread rainer juenger

Sorry but I am in another galaxy as you guys are. My problems are not that
complex yet and my knowledge isn't either.
I would only like to have a simple sample how I can access the Database
defined in the struts-config.xml without having to use any servlet depending
methodes/classes  like pageContext, sessions or what so ever. There must be
a way!

thanks 1000 times for a hint!

Rainer

- Original Message -
From: "Jerry Jalenak" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Monday, June 10, 2002 3:17 PM
Subject: RE: Database access design question


> I'm needing to move my data access from my Actions to a 'pure' business
> bean.  Does anyone have a good example (or link) on how to create and use
> DAO?
>
> Thanks.
>
> Jerry
>
> -Original Message-
> From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 3:43 AM
> To: Struts Users Mailing List
> Subject: RE: Database access design question
>
>
> 1. Do not use the session bean to access the datasource... create a data
> access object which locates the datasource.
> 2. Lookup the datasource using a jndi name not a servlet. Register your
> datasource with the jndi server. (Does the servlet api implement such a
> method ??)
> 3. If using a connection pool (which you should really), get the
connection
> object out of the pool and use it to access the database.
>
> HTH
> Vikram
>
>
> -Original Message-----
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 2:04 PM
> To: Struts Users Mailing List
> 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]>
>
>
> This transmission (and any information attached to it) may be confidential
and is intended solely for the use of the individual or entity to which it
is addressed. If you are not the intended recipient or the person
responsible for delivering the transmission to the intended recipient, be
advised that you have received this transmission in error and that any use,
dissemination, forwarding, printing, or copying of this information is
strictly prohibited. If you have received this transmission in error, please
immediately notify LabOne at (800)388-4675.
>
>
>
> --
> 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]>




RE: Database access design question

2002-06-10 Thread Robert Taylor

This is a subjective area. The Data Access Object is a design pattern which
really is
just a recommendation on how to implement access to the data store. There
are
several approaches, from home grown to commercial O/R products. Take a look
at Martin Fowlers site http://martinfowler.com/isa/index.html, Chuck
Caveness
book (chapter 6) http://www.theserverside.com/resources/strutsreview.jsp,
and then the archives are a great resource
http://www.mail-archive.com/struts-user%40jakarta.apache.org/.

HTH,

robert

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 10:14 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Database access design question
>
>
>
> Thanks for the feedback on that one.  No matter how I sliced that one I
> always had some kind of problem with how I was seperating everything
> up...
>
> I think the part that really confused me was that for this app, so far,
> there really is no business logic.  Its all lookups on the database...
>
> I took a quick look at the yahoo site - and will pursue that further,
> but can you recommend any write-ups anywhere on this?
>
> Thanks again...
>
>
>
>
> -Original Message-
> From: rtaylor [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:54 AM
> To: struts-user
> Subject: RE: Database access design question
>
>
> It sounds like your DAO is really a business object and your db object
> follows the DAO design pattern. I think you have the right concept
> though.
> You may want to check out http://groups.yahoo.com/group/model_struts/.
> It
> is dedicated to discussing the model layer using Struts.
>
> robert
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 9:39 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Database access design question
> >
> >
> >
> > 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.servle

RE: Database access design question

2002-06-10 Thread wbchmura


Thanks for the feedback on that one.  No matter how I sliced that one I 
always had some kind of problem with how I was seperating everything 
up...

I think the part that really confused me was that for this app, so far, 
there really is no business logic.  Its all lookups on the database... 

I took a quick look at the yahoo site - and will pursue that further, 
but can you recommend any write-ups anywhere on this?  

Thanks again...




-Original Message-
From: rtaylor [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 9:54 AM
To: struts-user
Subject: RE: Database access design question


It sounds like your DAO is really a business object and your db object
follows the DAO design pattern. I think you have the right concept 
though.
You may want to check out http://groups.yahoo.com/group/model_struts/. 
It
is dedicated to discussing the model layer using Struts.

robert

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:39 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Database access design question
>
>
>
> 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]>


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




RE: Database access design question

2002-06-10 Thread Robert Taylor

It sounds like your DAO is really a business object and your db object
follows the DAO design pattern. I think you have the right concept though.
You may want to check out http://groups.yahoo.com/group/model_struts/. It
is dedicated to discussing the model layer using Struts.

robert

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:39 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Database access design question
>
>
>
> 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]>


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




RE: Database access design question

2002-06-10 Thread wbchmura


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




RE: Database access design question

2002-06-10 Thread Jerry Jalenak

I'm needing to move my data access from my Actions to a 'pure' business
bean.  Does anyone have a good example (or link) on how to create and use
DAO?

Thanks.

Jerry

-Original Message-
From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 3:43 AM
To: Struts Users Mailing List
Subject: RE: Database access design question


1. Do not use the session bean to access the datasource... create a data
access object which locates the datasource.
2. Lookup the datasource using a jndi name not a servlet. Register your
datasource with the jndi server. (Does the servlet api implement such a
method ??)
3. If using a connection pool (which you should really), get the connection
object out of the pool and use it to access the database.

HTH
Vikram


-Original Message-
From: rainer juenger [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 2:04 PM
To: Struts Users Mailing List
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]>


This transmission (and any information attached to it) may be confidential and is 
intended solely for the use of the individual or entity to which it is addressed. If 
you are not the intended recipient or the person responsible for delivering the 
transmission to the intended recipient, be advised that you have received this 
transmission in error and that any use, dissemination, forwarding, printing, or 
copying of this information is strictly prohibited. If you have received this 
transmission in error, please immediately notify LabOne at (800)388-4675.



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




Re: Database access design question

2002-06-10 Thread rainer juenger

I am not sure but can I use JNDI when I configure the data-sources within
the struts-config.xml like:
  

  
How else can I access the datasource?

thx Rainer


> 1. Do not use the session bean to access the datasource... create a data
access object which locates the datasource.
> 2. Lookup the datasource using a jndi name not a servlet. Register your
datasource with the jndi server. (Does the servlet api implement such a
method ??)
> 3. If using a connection pool (which you should really), get the
connection object out of the pool and use it to access the database.
>
> HTH
> Vikram
>
>
> -Original Message-
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 2:04 PM
> To: Struts Users Mailing List
> 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]>
>
>


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




RE: Database access design question

2002-06-10 Thread Vikram Goyal01

1. Do not use the session bean to access the datasource... create a data access object 
which locates the datasource.
2. Lookup the datasource using a jndi name not a servlet. Register your datasource 
with the jndi server. (Does the servlet api implement such a method ??)
3. If using a connection pool (which you should really), get the connection object out 
of the pool and use it to access the database.

HTH
Vikram


-Original Message-
From: rainer juenger [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 2:04 PM
To: Struts Users Mailing List
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]>




Re: Database access design question

2002-06-10 Thread rainer juenger

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:

> For additional commands, e-mail:

>
>
> --
> To unsubscribe, e-mail:

> For additional commands, e-mail:

>
>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Database access design question

2002-06-10 Thread Vikram Goyal01

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:   
For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: