All users will definitely be application scope. To further that, it would probably be 
best to have a servlet, upon init of the container, start the connection pool and then 
register it via JNDI. Then your bean would be accessing that instead of creating it 
every time they are needed. The whole point behind connection pooling is for giving 
multiple objects, usually, over the scope of the application access to preconneted 
pools (sorry if this is review). Creating a new pool obj based on a request level 
scope pretty much defeats the purpose.

I'm actually working on dbcp at this level now. I just have a servlet start the pool 
when tomcat starts up. Pretty easy stuff. I'm interested in seeing how well the pool 
works vs. just getting a regular connection every time (I'm sure dbcp will smoke it).

cheers,

- Jason

-----Original Message-----
From:   Lev Assinovsky [mailto:[EMAIL PROTECTED]]
Sent:   Thu 3/14/2002 5:23 AM
To:     Jakarta Commons Developers List
Cc:     
Subject:        [dbcp] Works with JNDI, but some remarks...
Hello all!
I got dbcp working through JNDI in Tomcat 4.0.4b1.
Thank you! (I got tired of Tyrex :-))

But I have several issues.

My configuration server.xml is:
         <Resource name="lev/DataSource" auth="Container"
                    type="javax.sql.DataSource"/>
          <ResourceParams name="lev/DataSource">
           <parameter><name>factory</name>
              
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
           </parameter>
 
            
<parameter><name>username</name><value>wv</value></parameter>
           
<parameter><name>password</name><value>wv</value></parameter>
            
<parameter><name>maxActive</name><value>100</value></parameter>
            
<parameter><name>maxIdle</name><value>30000</value></parameter>
            
<parameter><name>maxWait</name><value>100</value></parameter>
            <parameter><name>driverClassName</name>
              <value>org.gjt.mm.mysql.Driver</value></parameter> 
            <parameter><name>url</name>
             
<value>jdbc:mysql://localhost:3306/WV?user=wv&amp;password=wv</value></parameter> 
          </ResourceParams>

1. When I had 'user' instead of 'username' (Tyrex allows both) I got
NullPointer exception
in connectionProperties.put("user", username) in BasicDataSource.

2. When I didn't have maxActive I got infinite loop in  borrowObject()
in GenericObjectPool.

Actually I don't have clear understanding of the pool's parameters.
I'all really appreciate 
if somebody could make it clear for me.
 
Also with xml  parameters above I got very often:
 
java.sql.SQLException: Communication link failure: java.io.IOException
        at org.gjt.mm.mysql.MysqlIO.clearAllReceive(Unknown Source)
        at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)
        at org.gjt.mm.mysql.MysqlIO.sqlQuery(Unknown Source)
        at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)

or 
  NullPointerException.

However I created new connection pool (through JNDI lookup) on every
HTTP request since my bean where I did all above
had a scope="request" (just for testing).

And the last GLOBAL question. If I get datasource and connection in the
bean, then 
the only way to have one connection pool for all users who sends HTTP
request to my JSP (which using my bean)
is to have the scope "application" for the bean. Am I right?

Sincerely,
-- 
Lev Assinovsky                Peterlink Web
Programmer                    St. Petersburg, Russia
Tel/Fax: +7 812 3275343       197022 ul.Chapigina 7?
E-mail: [EMAIL PROTECTED]

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




<<winmail.dat>>

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

Reply via email to