I agree with this. We use Tomcat to set up the connection pool and
reference it in our Struts apps as Craig suggests above. Take a look
at the Tomcat documentation, there is quite a bit on JNDI and
datasources.
Good luck,
sean
On Wed, 20 Oct 2004 11:00:11 -0700, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> More modern advice suggests that you don't use a Struts-provided
> connection pool at all ... use the JNDI factilities provided by your
> servlet container or app server. Then, you gain access to a
> connection pool provided by the server, like this:
>
> InitialContext ic = new InitialContext();
> DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/CustomerDB");
>
> without having to pass any parameters around.
>
> Craig
>
> On Wed, 20 Oct 2004 13:36:27 -0400, [EMAIL PROTECTED]
>
>
> <[EMAIL PROTECTED]> wrote:
> >
> > Found this at http://www2.real-time.com/rte-tomcat/2000/Jun/msg01487.html
> > --
> >
> > The suggested approach is to store your connection pool object itself as
> > a servlet context attribute, like this:
> >
> > ConnectionPool pool = new ConnectionPool( ... );
> > getServletContext().setAttribute("pool", pool);
> >
> > Now, any servlet (or JSP page) in this web application can gain access
> > to the connection pool:
> >
> > ConnectionPool pool = (ConnectionPool)
> > getServletContext().getAttribute("pool");
> >
> > without needing to gain access to a servlet instance itself.
> >
> > Craig McClanahan
> >
> >
> >
> >
> > Matt Hughes <[EMAIL PROTECTED]>
> >
> > 10/20/2004 01:28 PM
> >
> > Please respond to
> > "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >
> >
> > To "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> >
> > cc
> >
> > Subject Getting DataSource from non-Struts class
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > I am developing a web service for my application and am putting the
> > class in the same web context as the rest of my struts application.
> > However, I want to be able to get a DataSource object from within this
> > class. The only thing I have to connect the two is a ServletContext
> > object. How can I call Struts or get a hold of this DataSource object
> > when I am not in an Action class, etc.
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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]
> >
> >
>
> ---------------------------------------------------------------------
>
>
> 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]