tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject DBCP - BasicDatasource?
Date Thu, 23 May 2002 23:13:33 GMT

I've got a question about setting up a connection pool using DBCP.
Back when I was testing the nightly build from 20020404, I could swear
I was getting back a PooledDataSource.  Now with todays build
(20020523), I am getting back a BasicDatasource.

The code that I have looks like:

        DataSource ds = null;
        try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            if (envCtx!=null) {
                ds = (DataSource)envCtx.lookup("jdbc/utasklistDB");
                System.out.println("The Datasource is: " + ds);
            }
        } 
        catch (NamingException ne) {
            System.out.println("JNDI Lookup Failed: " + ne.getMessage());    
        }
        return ds.getConnection();

What prints out on that first println is:
The Datasource is: org.apache.commons.dbcp.BasicDataSource@22220f

Then, when I attempt to return the connection, I end up getting the
following error:

java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:380)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(Unknown Source)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(Unknown Source)
        at com.syntegra.unilever.tasklist.data.ConnectionManager.getConnection(ConnectionManager.java:73)
        at com.syntegra.unilever.tasklist.data.Manager.openConn(Manager.java:22)
        at com.syntegra.unilever.tasklist.data.UserManager.getUserByUsername(UserManager.java:201)
        at com.syntegra.unilever.tasklist.services.ValidationServices.validateUser(ValidationServices.java:91)
        at com.syntegra.unilever.tasklist.services.ValidationServices.validateUser(ValidationServices.java:69)
        at com.syntegra.unilever.tasklist.MasterEventGateway$LocalRequestHandler.handleControlEvent(MasterEventGateway.java:80)
        at org.enhydra.barracuda.core.event.DefaultBaseEventListener.handleEvent(DefaultBaseEventListener.java:64)
        at org.enhydra.barracuda.core.event.DefaultEventDispatcher.notifyListeners(DefaultEventDispatcher.java:381)
        at org.enhydra.barracuda.core.event.DefaultEventDispatcher.dispatch(DefaultEventDispatcher.java:183)
        at org.enhydra.barracuda.core.event.DefaultEventDispatcher.dispatchEvent(DefaultEventDispatcher.java:103)
        at org.enhydra.barracuda.core.event.DefaultEventBroker.dispatchEvent(DefaultEventBroker.java:488)
        at org.enhydra.barracuda.core.event.ApplicationGateway.handleDefaultExt(ApplicationGateway.java:413)
        at org.enhydra.barracuda.core.event.ApplicationGateway.handleDefault(ApplicationGateway.java:239)
        at org.enhydra.barracuda.core.event.ApplicationGateway.doGet(ApplicationGateway.java:632)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)
        at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardContext.invoke(Unknown Source)
        at org.apache.catalina.core.StandardHostValve.invoke(Unknown Source)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown
Source)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke(Unknown Source)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown
Source)
        at org.apache.catalina.valves.ErrorReportValve.invoke(Unknown Source)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:458)
        at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:551)
        at java.lang.Thread.run(Thread.java:484)


So...

First, should BasicDataSource rather than PooledDataSource be
returned?  If so, why?  How do I utilize a database pool?

Second, why the null pointer at ds.getConnection()?  I wasn't getting
that before in my previous nightly build, although I was having other
issues where it wasn't working, which I won't get into here, but ds.getConnection() did return
a
Connection object rather than throw a null pointer exception.

Any hints as to what is up with this?  I realize that this is alpha
software, but I'd like to know if I'm even on the right track or if
something in the design has changed...and maybe I should be using DBCP
some different way than I am now???

Jake


-- 
Best regards,
 Jacob                          mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message