Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes Connection pooling problem in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Connection pooling problem in Tomcat" Watch "Connection pooling problem in Tomcat" New topic

Connection pooling problem in Tomcat

Ganesh Chandrasekaran

Joined: Nov 14, 2000
Posts: 22

Can some one help me with the connection pooling problem in Tomcat5.*

I get the message
Cannot connect to database serverorg.apache.tomcat.dbcp.dbcp.SQLNestedException:
Cannot create JDBC driver of class '' for connect URL 'null'

I have updated the server.xml and web.xml files as per the document

In server.xml between the <Host></Host> tags i have added the following

<Resource name="jdbctestprojectDB" auth="Container" type="javax.sql.DataSource"/>

<ResourceParams name="jdbctestprojectDB">


AND in web.xml added the following between <web-app></web-app> tags


And in the Jsp page the code is

<%@ page import="java.util.Date" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>

Context initContext = new InitialContext();

Context envContext = (Context)initContext.lookup("java:/comp/env");

DataSource ds = (DataSource)envContext.lookup("jdbctestprojectDB");

Connection conn = ds.getConnection();


Rama Krishna Ghanta
Ranch Hand

Joined: Nov 20, 2006
Posts: 59
check whether you have the proper mysql jar file in your classpath. Also I don't think you should use InitialContext and lookup if you are working with Tomcat. We normally use these if we are doing Connection Pooling in an Application server.

Ganesh Chandrasekaran

Joined: Nov 14, 2000
Posts: 22
Dear Rama Krishna,

Thanks for your reply.

It works when i use the context.xml file in the META-INF
directory. But when i try to use by configering in the
server.xml and web.xml as per the tomcat document it doen't work.

Milan Jagatiya
Ranch Hand

Joined: Jan 01, 2007
Posts: 164
Hi, which version you are using?... if you are using 5.5.7 then put context.xml file in your web root's META-INF directory. and put following code

it works if your version is 5.5.7 enjoyyyyy.... milan. :thumb:

Milan.<br />I can because I think I can...
I agree. Here's the link:
subject: Connection pooling problem in Tomcat
Similar Threads
Tomcat with MySQL Connection Pool
Configure tomcat resource factory
Databse Connectivity Error
Configuring Tomcat's Resource Factory...
Pooling w/Tomcat 5 - Oracle