Peter, thanks much for the lesson.  You've hit on my
first (and unmentioned problem) - Poolman choked with
mysql 3.23.41 with the level setting error.  I'll try
3.23.46...  I'm excited to try your suggestions, but
unfortunately I have a 'real' job that will delay my
efforts.  I'm new to the open source world, but
continue to be amazed at the wealth of knowledge and
time people are willing to share to bring 'newbies' up
to speed.


--- Peter Kordel <[EMAIL PROTECTED]> wrote:
> Andy, I use Poolman in a Struts application and did
> it this way:
> Downloaded poolman-2.1-b1 (you can even use CVS to
> pull the latest
> version from their site)
> Configured poolman.xml to work with mysql
> 3.23.46/mm.mysql-2.0.8 and
> stuck it in WEB-INF/classes of my web app 
> BTW this works for both tomcat 3.2.4 and 4.0.1 -
> with struts-1.0
> Then I preload an initservlet on startup that grabs
> a Poolman
> datasource.
> It also tears down all pools in destroy()
> This datasource is stored in a connectionholder
> object in the
> servletcontext that acts as a wrapper for Poolman.
> I used this extra layer of abstraction so I can pull
> a generic
> datasource from the servletcontext and call methods
> such as
> getConnection() and closeConnection() that in turn
> call the correct
> methods in Poolman. That way, I can plug-and-play
> with alternative
> connection pools without modifying my application
> objects.
> 
> // set up a connection pool with
> // <dbName> from web.xml initparam
> javax.sql.DataSource defaultPool = 
>       PoolMan.findDataSource(dbName);
> 
> zConnectionHolder dsPool = 
>       new zConnectionHolder();
> 
> dsPool.setDefaultPool(defaultPool);
> context.setAttribute("dsPool",  dsPool);
> 
> Then I proceed like you:
> zConnectionHolder dsPool = 
>       (zConnectionHolder) servlet.getServletContext()
>                                  .getAttribute("dsPool");
> java.sql.Connection con = 
>       dsPool.getConnection();
> 
> dsPool.closeConnection();
> 
> Works like a charm. Your error makes no mention of
> anything that looks
> like a non-tomcat or non-struts object, so it's
> probably a config error
> in setting up you web app with tomcat/struts
> I work like this: develop in a source directory,
> then deploy to the
> servlet container (with ant), with a "clean" target
> if needed, and then
> bounce tomcat (and apache, if in the loop). I have
> even run into the
> need to shut down tomcat, whack my web app *and*
> tomcat/work directories
> before deploying - primarily on Unix. And - turn on
> as much debugging as
> possible initially. *Logs are your friend*
> Many pieces have to be happy for it all to work, and
> they will be happy
> to let you know if they don't play well with other
> children. Also, don't
> do what I do: fix 50 things at once, instead debug
> incrementally by
> changing one thing at a time.
> 
> Be aware that mysql versions 3.23.36 and below fail
> miserably with
> Poolman, as Poolman tries to set transaction levels
> and mysql barfs in
> technicolor.
> 
> 
> Andy Timm wrote:
> > 
> > Hello.  I am trying to implement a DB connection
> > manager with my Struts webapp.  I created a
> servlet
> > that gets called when Tomcat is initialized, that
> > creates a DbConnectionBroker, and puts it in the
> > ServletContext:
> > getServletContext().setAttribute("dbPool",
> dbPool);
> > 
> > In a 'ActionForm', I'm validating a username
> against
> > the database, so I grab the dbPool object to pass
> into
> > my database bean:
> > DbConnectionBroker pool =
> >
>
(DbConnectionBroker)servlet.getServletContext().getAttribute("dbPool");
> > 
> > This works fine for the first page.  When I
> attempt to
> > access the next page (any other following page),
> right
> > after the "checkLogin" tag is called, it throws
> the
> > exception below.  Two questions...  First, I would
> > like to utilize Struts datasource mapping, but
> don't
> > know how to do so while using a different
> connection
> > manager.  (There was a post yesterday suggesting
> > Poolman... ) Second, what am I doing wrong so that
> I
> > cannot access my next page?  The 'Action' called
> after
> > the working page executes normally, then it dies. 
> I'm
> > loading two servlets (action, and my initDBPool)
> in
> > web.xml.  Is there some rule about which must be
> > loaded first?  I'm new to the whole servlet thing,
> but
> > it seems like it's looking to my initDBPool
> servlet
> > for information it should find elsewhere (hence
> the
> > IncompatibleClassChangeError).  I would be most
> > grateful if someone could explaine the 'proper'
> method
> > for merging connectionPooling with Struts - but
> I'd be
> > happy for a solution for my problem at hand too...
> > Thanks, Andy Timm
> > 
> > java.lang.IncompatibleClassChangeError
> >         at
> >
>
_0002fregister_0002ejspregister_jsp_0._jspService(_0002fregister_0002
> > ejspregister_jsp_0.java:578)
> >         at
> >
>
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
> >         at
> >
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >
>
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
> > vlet.java:177)
> >         at
> >
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
> > 18)
> >         at
> >
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
> >         at
> >
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >
>
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
> > 04)
> >         at
> >
>
org.apache.tomcat.core.Handler.service(Handler.java:286)
> >         at
> >
>
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
> > )
> >         at
> >
>
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatc
> > herImpl.java:194)
> >         at
> >
>
org.apache.struts.action.ActionServlet.processActionForward(ActionSer
> > vlet.java:1758)
> >         at
> >
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:159
> > 5)
> >         at
> >
>
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:491)
> >         at
> >
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> >         at
> >
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at
> >
>
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
> > 04)
> >         at
> >
>
org.apache.tomcat.core.Handler.service(Handler.java:286)
> >         at
> >
>
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

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

Reply via email to