Hi!
I have maybe a simple question:
My web-app has to get data out of a database. I have a class DatabaseHandler
which
holds a connection to the database and provides methods to query it. I would
like to
have only one instance of this class in my web-app. But I don't know where
to put it.
Should
Should it be stored in the ServletContext for application scope? But
how do
I access
this instance from my Actions?
getServlet().getServletContext().getAttribute(xxx)
Or would it be better to use data-sources? If
I should
use them, does anybody know a good tutorial on the internet? Perhaps
Should it be stored in the ServletContext for application scope? But
how do I access this instance from my Actions?
getServlet().getServletContext().getAttribute(xxx)
is it the same as request.getSession().getServletContext().getAttribute(xxx)
?
Peter
[EMAIL PROTECTED] a écrit :
Should it be stored in the ServletContext for application scope? But
how do I access this instance from my Actions?
getServlet().getServletContext().getAttribute(xxx)
is it the same as request.getSession().getServletContext().getAttribute(xxx)
?
Yes.
--
Yes. Check with servlet-APIdoc...
Alexander
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 06, 2005 11:10 AM
To: user@struts.apache.org
Subject: AW: Newbie: Where to put instance for database access?
Should it be stored in the ServletContext
Create a singleton class, that holds the instance of a connection in a
ThreadLocal class in that singleton --
this way you don't have to keep stuff in the session...
Regards, Alex.
On 7/6/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi!
I have maybe a simple question:
My web-app has
You should be using some type of data source or preferrably a
connection pool based on a data source. Most web servers include a
connection pool implementation and all that's needed is to define the
connection pool, define the data source, and then link the two. Your
web app will then get a
to
Struts Users Mailing List user@struts.apache.org
To
Struts Users Mailing List user@struts.apache.org
cc
Subject
Re: Newbie: Where to put instance for database access?
Create a singleton class, that holds the instance of a connection in a
ThreadLocal class in that singleton
8 matches
Mail list logo