Re: Still need help! - DBCP/DB2/Tomcat 4.1.24 problem!

2004-12-23 Thread Parsons Technical Services
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" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" 
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 \common\lib.
This code snippet works:
...
String url = "jdbc:db2://myserver:5/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)
--
...

  
 
  
  factory
  org.apache.commons.dbcp.BasicDataSourceFactory
  

  username
  test
  

  password
  password
  

  driverClassName
  com.ibm.db2.jcc.DB2Driver
  

  url
  jdbc:db2://myserver:5/mydb
  


--
web.xml
--
...

 jdbc/mydb
 javax.sql.DataSource
 Container

So, that is pretty much it. I have consulted 2 books, countless
websites, and would appreciate any help.
Thanks
JW

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


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


Still need help! - DBCP/DB2/Tomcat 4.1.24 problem!

2004-12-23 Thread James Milks
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 \common\lib.

This code snippet works:
...
String url = "jdbc:db2://myserver:5/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)
--
...

   

  
   
   factory
   org.apache.commons.dbcp.BasicDataSourceFactory
   

   username
   test
   

   password
   password
   

   driverClassName
   com.ibm.db2.jcc.DB2Driver
   

   url
   jdbc:db2://myserver:5/mydb
   



--
web.xml
--
...

  jdbc/mydb
  javax.sql.DataSource
  Container



So, that is pretty much it. I have consulted 2 books, countless
websites, and would appreciate any help.

Thanks

JW



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