There have been a couple of reports on this (e.g.,
<http://issues.apache.org/bugzilla/show_bug.cgi?id=14267>), but it doesn't
seem to be universal.

Oddly, it always seems to be this property (driver name) that isn't
getting passed.

I've been having trouble re-creating this problem personally, but I can
try to poke around a bit more if I get a chance.  Perhaps someone more
intimate with the Tomcat JNDI code can try to take a look as well?

On Fri, 13 Dec 2002, MANOHARAN,MADHAN (HP-PaloAlto,ex1) wrote:

> 1.  Yes, the driver exists in the common/lib directory.
> 2.  I wrote a quick test method in the same java class I wrote to test the
> connection pool and it works just fine.
> 3.  I compared the server.xml with the one on the DBCP site(I had already
> looked @ the file a 100 times before) and it looks just fine.
> 4.  I checked the web.xml to make sure the resource ref name is the same.
>
> The problem still exists.  I'm trying to install oracle and check against
> that just to eliminate the possibility that the problem is from the
> database/driver.
> I appreciate your help Jonathan.  Thanks.
>
> Madhan
>
> -----Original Message-----
> From: Jonathan Mangano [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 10:58 AM
> To: Jakarta Commons Users List
> Subject: RE: Connection pool nightmare!
>
>
> By the looks of it you don't have the driver class specified properly in
> your server.xml. To debug this problem:
>
> 1. Check that your jdbc driver is in the <TomcatHome>/common/lib directory
>
> 2. Write a quick test class to check the driver name, driver url, username
> and password you are using. Something very simple like: Driver jsqlDriver =
> (Driver) Class.forName(jsqlDriverName).newInstance();
> Connection conn = DriverManager.getConnection(driverUrl, userName,
> password);
>
> 3. If this works open your server.xml in <TomcatHome>/conf and compare it to
> the example at
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
> to.html#Database%20Connection%20Pool%20(DBCP)%20Configurations just
> switching the driver name, driver url, username and password with your own.
>
> 4. Open your web.xml and also check it against the example above to see if
> everything is properly configured
>
>
> -----Original Message-----
> From: MANOHARAN,MADHAN (HP-PaloAlto,ex1) [mailto:[EMAIL PROTECTED]]
> Sent: December 13, 2002 1:17 PM
> To: 'Jakarta Commons Users List'
> Subject: Connection pool nightmare!
>
>
> Hi guys,
>   I bet there were many postings on this issue before.  I searched the
> archive, but couldn't figure out a way to solve this and so posting again. I
> use SQL Server 2000, JDBC drivers from MS for SQL Server 2000, Tomcat 4.1.6,
> windows XP.  I was trying to implement connection pooling and this is what I
> did
>
> 1) created a connection pool from tomcat admin(pointing to
> http://localhost:8080/admin) ).  I did use the datasource driver from
> MS(com.microsoft.jdbcx.sqlserver.SQLServerDataSource) for the
> driverclassname.
> 2) created a web.xml with the Resource reference entry
> 3) created a simple java class where I lookup the context via jndi and try
> to get a connection.
> 4) created a jsp to call the java class.
>
> When I hit the jsp, it calls the java class.  The java class looks up the
> datasource and finds it( I guess), but when I try to get the connection, I
> get this error
>
> java.sql.SQLException: Cannot load JDBC driver class 'null'
>         at
> org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav
> a:529)
>         at
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:3
> 12)
>         at foo.DBTest.init(DBTest.java:32)
>         at org.apache.jsp.test_jsp._jspService(test_jsp.java:50)
>         at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
> >From what I see, Tomcat is not able to load the driver class for some
> reason.  The jar files are in the classpath and also in the tomcat common
> lib directory.
>
> This is the method in the java program which tries to use the pool:
>
> public void init() {
>     try{
>       Context ctx = new InitialContext();
>       if(ctx == null )
>           throw new Exception("Boom - No Context");
>         Context env = (Context)ctx.lookup("java:comp/env/jdbc");
>         System.out.println("Environ contxt   "+env);
>         Enumeration e = env.list("");
>         while(e.hasMoreElements())
>         {
>                 System.out.println("Environment element
> "+e.nextElement());
>         }
>       DataSource ds =(DataSource)env.lookup("CPSDataSource");
>       System.out.println("Lookup successful...");
>       if (ds != null) {
>         Connection conn = ds.getConnection();
>         if(conn != null)  {
>             foo = "Got Connection "+conn.toString();
>             Statement stmt = conn.createStatement();
>             ResultSet rst =
>                 stmt.executeQuery(
>                   "select ID from TEST");
>             if(rst.next()) {
>                foo=rst.getString(2);
>                bar=rst.getInt(3);
>             }
>             conn.close();
>         }
>       }
>     }catch(Exception e) {
>       e.printStackTrace();
>     }
>  }
>
> I also tried looking up "jdbc/CPSDataSource" from the "java:comp/env"
> context; I'm looking up the "java:comp/env/jdbc" to make sure the
> CPSDataSource context exists and print the context variables in the program.
>
> Could someone throw some light on whatz wrong or why this fails?
>
> Thanks,
> Madhan
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to