Hi,

I have the same problem. Want connection pool to work on Tomcat and Websphere
without to rewrite code. IBM send us instructions to set up the server and a
piece of code that looks like this:

...
java.util.Properties parms = new java.util.Properties();
            parms.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
            javax.naming.Context ctx = new
javax.naming.InitialContext(parms);
            javax.sql.DataSource ds =
(javax.sql.DataSource)ctx.lookup("jdbc/db2proddb02DS");
            java.sql.Connection c = ds.getConnection(user,pass);
...

It works on Websphere, but as you can see, initial conext is provided by
Websphere code, and I won't use that in Tomcat (in fact I think this is EJB
code, and Tomcat does not support it; I can't use it even if I want to).

So I'm trying an alternate path:

...
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.sql.DataSource ds =
(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/db2proddb02DS");
java.sql.Connection c = ds.getConnection(user,pass);
...

And on /conf/server.xml

<!--  MyApp Context -->
        <Context path="/myapp" docBase="myapp" debug="0"
                 reloadable="true" crossContext="true">

          <!-- Pool de Conexao DB2 -->
          <Resource name="jdbc/db2proddb02DS" auth="SERVLET"
                    type="javax.sql.DataSource"/>
            <ResourceParams name="jdbc/db2proddb02DS">
             <parameter><name>user</name><value></value></parameter>
             <parameter><name>password</name><value></value></parameter>
             <parameter><name>driverClassName</name>

<value>COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource</value></parameter>
             <parameter><name>driverName</name>
              <value>jdbc:db2:database</value></parameter>
            </ResourceParams>
        </Context>

I'm still getting a "Null Pointer" error, but I think that when I got it to
work, I might use the very same configuration (and code) on both servers, since
COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource it's not Websphere code.

Hope it helps. And note that I may be wrong :) Perhaps one of the fine people in
this list may correct me.

Fabio.

D Watson wrote:

> I am testing under Tomcat but I will be deploying the project to WebSphere
> (as per the client's request). I would like to be able to have the project
> work under any application server, so I do not want to rely on a 3rd party
> product for pooling but rather use a built in solution (if available).  In
> doing this I also hope to keep any application server specific
> coding/configuration to a minimum.

--
Fabio Mengue - Centro de Computacao - Unicamp
[EMAIL PROTECTED]       [EMAIL PROTECTED]
"Quem se mata de trabalhar merece mesmo morrer." - Millor




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

Reply via email to