File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat 5.5.9 getting Database Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 5.5.9 getting Database Connection" Watch "Tomcat 5.5.9 getting Database Connection" New topic

Tomcat 5.5.9 getting Database Connection

Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
I am having trouble getting a database connection using Tomcat 5.5.9 on WIndows XP. Here is what I have:

* I have put mysql-connector-java-3.1.10-bin.jar in TOMCAT_HOME/common/lib/directory
* I create a context.xml file that I put in the meta-inf directory of my war file. Here is the contents:

<Context path="/quickstart" docBase="quickstart" debug="1" reloadable="true">
<Resource name="jdbc/quickstart" auth="Container" type="javax.sql.DataSource"
username="quickstart" password="quickstart"

* in my web.xml I have:

<web-app xmlns=""
<description>Hibernate Test</description>
<description>DB Connection</description>

* in my servlet I just have some code that does:

When I run this servlet, I get the following message print out from the catch clause above:

Cannot create JDBC driver of class '' for connect URL 'null'

It can't seem to find the class. Should I put the context.xml somewhere else or has anyone had success putting it in the meta-inf directory? Any help would be apprectiated!
[ July 07, 2005: Message edited by: Brian Nice ]
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Something you can try -

Rename your context.xml file to quickstart.xml (not exactly required though, i think) , and place it under TOMCAT_HOME/conf/Catalina/localhost.

There is more information on deploying applications in Tomcat at


The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
Great, that worked. Any idea on why it doesn't work under the meta-inf directory? that is what the documentation seems to want you to do
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

I didnt read the documentation throughly, but from what I remember, the context information is picked from META-INF directory only when you use one of the Tomcat tools (Deployer?Manager?) to deploy the application.

This may not be done under other conditions, for example if you are deploying an expanded directory or manually copying a war to webapps.

I agree. Here's the link:
subject: Tomcat 5.5.9 getting Database Connection
It's not a secret anymore!