I'm trying to configure Tomcat to use a DB2ConnectionPoolDataSource, but
I'm experiencing problems which appear to be related to configuration -
more specifically the datasource I've defined in the server.xml file, and
the datasource returned from the InitialContext within the code are
different.  I receive a "Cannot create JDBC driver of class
'COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource' " exception

Maybe this situation is best described with code.

In server.xml
<Context path="/emsl" docBase="emsl" debug="0" reloadable="true"
crossContext="true">
<Resource name="jdbc/emsltestds" auth="SERVLET" type
="javax.sql.DataSource"/>
<ResourceParams name="jdbc/emsltestds">
<parameter>
<name>user</name><value>username</value>
</parameter>
<parameter>
<name>password</name><value>userpassword</value></parameter>
<parameter>
<name>driverClassName</name><value>COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource</value>
</parameter>
<parameter>
<name>driverName</name><value>jdbc:db2:rtmwasdb</value>
</parameter>
<parameter>
<name>url</name><value>//9.17.41.96:50000</value>
</parameter>
</ResourceParams>
</Context>

In web.xml
<resource-ref>
<description>DB2 Connection</description>
<res-ref-name>jdbc/emsltestds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

the code in my servlet
try {
      Context jndiCntx = new InitialContext();
      out.println("new InitialContext<br>");
      DataSource ds = (DataSource)jndiCntx.lookup
("java:comp/env/jdbc/emsltestds");
      out.println("got a DataSource<br>");
      out.println(ds.toString() + "<br>");
      out.println( (ds instanceof org.apache.commons.dbcp.BasicDataSource)
+ "<br>");
      out.println( (ds instanceof
COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource) + "<br>");
      conn = ds.getConnection();   // exception is thrown here
      ....
} catch (Exception e) {
      out.println("Problems: " + e.toString());
}

and finally the end result viewed with a web browser....
new InitialContext
got a DataSource
org.apache.commons.dbcp.BasicDataSource@7200b4
true
false
Problems: java.sql.SQLException: Cannot create JDBC driver of class
'COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource' for connect URL
'//9.17.41.96:50000'

What is weird to me is if you notice the debug statements, I echo out
"ds.toString()" which gives me
org.apache.commons.dbcp.BasicDataSource@some_memory_address.  I think this
might be where at least one of my problems reside.  Seems to me this should
be COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource@some_memory_address - maybe
I need additional information in the server.xml file?!?!

Any ideas/pushes in the right direction are greatly appreciated.  Thanks in
advance.

Andrew D Johnson
IBM Global Services
Enterprise Monitoring Solutions Lab
(303) 924-6951  5-6951 T/L 263-6951
[EMAIL PROTECTED]

This is not rocket science - its only suborbital ballistic propulsion
engineering



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

Reply via email to