tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Parsons Technical Services" <parsonstechni...@earthlink.net>
Subject Re: Still need help! - DBCP/DB2/Tomcat 4.1.24 problem!
Date Thu, 23 Dec 2004 21:57:53 GMT
James,

Two things that I see that you may want to try.

1. Change Resourceparams to ResourceParams

2. Check the documentation on the DB2 drivers for the proper way to pass the 
parameters. Some drivers cannot handle certain parameters from the xml. Some 
have to be included in another parameter.


If nothing shows up with those read over this and see if anything helps.

http://www.experts-exchange.com/Web/Application_Servers/Q_20460211.html

Doug


----- Original Message ----- 
From: "James Milks" <jamesm@videotron.ca>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Thursday, December 23, 2004 12:40 PM
Subject: Still need help! - DBCP/DB2/Tomcat 4.1.24 problem!


> Hi,
> despite the fact that I did get some responses (and a thread hijack), I
> am still trying to solve this. Any help appreciated.
>
> I am trying to get DBCP connection pooling to work with Tomcat 4.1.24
> and DB2 8.X. I can connect directly, but whenever I try to use DBCP, I
> receive a "Cannot load driver class 'null'" error. The DB2 and JNDI jar
> files are located in <tomcat-root>\common\lib.
>
> This code snippet works:
> ...
> String url = "jdbc:db2://myserver:50000/mydb";
> String user = "test";
> String pass = "password"; Class.forName("com.ibm.db2.jcc.DB2Driver");
> Connection conn = DriverManager.getConnection(url,user,pass);
> Statement stmt = conn.createStatement();
> ResultSet myRs = stmt.executeQuery("select * from myTable"); ...
>
> This leads me to believe that:
> a) My driver is fine and jar file location is ok
> b) My login credentials are fine
> I use the same driver and connection info in my DBCP config.
>
> -------------------------------------------
> Now when I try to use DBCP, this code snippet does NOT work. ... Context
> jndiCtx = new InitialContext(); Context ctx = (Context)
> jndiCtx.lookup("java:comp/env"); DataSource ds = (DataSource)
> ctx.lookup("jdbc/mydb"); Connection conn = ds.getConnection(); Statement
> stmt = conn.createStatement(); ResultSet myRs =
> stmt.executeQuery("select * from myTable"); ...
>
> Tomcat does not throw any errors at startup in any logs and when I
> execute the above code, the DataSource retrieved (ds) is not null and a
> getClassName() call reveals a generic commons DataSource object.
> However, once it gets to the getConnection() method, the evil "Cannot
> load driver class 'null'" error occurs.
>
> I tried messing around with the JNDI entries to prove that was OK, and
> as expected I get a naming error if I put a wrong value. This tells me
> that the "lookup" portion works, yes?
>
> Here are the relevant server.xml and the web.xml entries:
>
> ------------------------------------------------------
> server.xml (note: I also tried it without the factory param)
> ------------------------------------------------------
> ...
> <Context...>
>   <Resource name="jdbc/mydb" scope="Shareable"
> type="javax.sql.DataSource" auth="Container" />
>
>  <Resourceparams name="jdbc/mydb">
>   <parameter>
>   <name>factory</name>
>   <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>   </parameter>
> <parameter>
>   <name>username</name>
>   <value>test</value>
>   </parameter>
> <parameter>
>   <name>password</name>
>   <value>password</value>
>   </parameter>
> <parameter>
>   <name>driverClassName</name>
>   <value>com.ibm.db2.jcc.DB2Driver</value>
>   </parameter>
> <parameter>
>   <name>url</name>
>   <value>jdbc:db2://myserver:50000/mydb</value>
>   </parameter>
> </Resourceparams>
> </Context>
>
> ------------------------------------------------------
> web.xml
> ------------------------------------------------------
> ...
> <resource-ref>
>  <resource-ref-name>jdbc/mydb<resource-ref-name>
>  <res-type>javax.sql.DataSource</res-type>
>  <res-auth>Container</res-auth>
> </resource-ref>
>
>
> So, that is pretty much it. I have consulted 2 books, countless
> websites, and would appreciate any help.
>
> Thanks
>
> JW
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
> 



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


Mime
View raw message