my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes MySQL Error - no driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MySQL Error - no driver" Watch "MySQL Error - no driver" New topic

MySQL Error - no driver

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hi guys,

Yes another MySQL error post.

I've read through the other posts but cant seem to get to the bottom of my problem.

I've put the MySQL driver jar file in the common's folder. It is also in my buildpath too.

my error is as follows:

Where could this problem be? the web.xml? server.xml?? the driver itself? my code is from here

My web.xml is as follow. Server.xml follows the

Any ideas? It's driving me mad now.

Thanks in advance regards

PS: I didnt want to cross post, unfortunately I think this is a half server half JDBC problem.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

where is the connection pool class located?
My guess at the moment is that you have a classloader problem in the location of your two jars. Personally I would delete them both from from where ever they are and place them both in the <context>/WEB-INF/lib directory.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hi guys

RE: the previous post.

where is the connection pool class located?

Is this the .jar file (mysql-connector-java-5.0.4-bin-g.jar)?? I copied this into the ....Tomcat 5.5\common\lib directroy only.

Now, as Dave said above I moved to the webapps/myapp/WEB-INF/lib (so there is only one copy). Still I have the same problem.

It seems to be quite a basic thing to be honest, i'm sure alot of people must have had this sort of issue?

Oh and the jar file is in my IDE's classpath too.

Any ideas?? Considering :P

Thanks in advance
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
The message is no suitable driver.

Did you check if the mysql driver is compatible with with your mysql version.

Is it tested in a standalone program without Tomcat.

I had once the same problem, which was solved by putting the right JDBC-driver.

Also check if in Tomcat there is no cross reference to a different driver, but I understand this is already done.

Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

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

The driver factory looks up the driver that matches your connect string.
Your connect string seems to be empty.

Looking from your post, you've created a resource reference to a datasource, but you haven't defined the resource itself (jdbc/TestDB) completely.

In the howto page you talk about in your first post, there is a section for server.xml, where you have to define the datasource.

Did you include this in your setup?

Regards, Jan
[ February 17, 2007: Message edited by: Jan Cumps ]

OCUP UML fundamental and ITIL foundation
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hi guys,

Still stuck on this problem.

MySQL works on its own fine. I have entered data, no problem. I can also retrieve the required data.

I'm trying to run the connection stand alone (as recommended by Wilhelm Tell, above), this is causing problems. I have the driver in the classpath but I still have error

(I have read that this is due to the driver not being configured properly).

I added the jar to my classpath (i'm using eclipse), it shows that it is in the classpath too.

MySQL is version 5.0.27 driver version is mysql-connector-java-5.0.4-bin-g.jar

Any cues?
Thanks in advance.

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Further to the abover I have my database on my C:\ drive, not on a server or anything. Is this ok? (even when I connect to the MySQL via Tomcat).

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
If you're getting that error, it doesn't have anything to do with the driver. It means that your .class file can't be found.

Eclipse and other IDEs often override the system CLASSPATH. What is the CLASSPATH you have?
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Ok guys,

I've finally got to the bottom of this problem.

Yes also as Keith mentioned in the above post the classpath for the class I was executing had to be set (I write all my test programs in another package which wasn't in the classpath).

The mysql-connector-java-5.0.4-bin-g.jar has to be placed in the C:\Program Files\Java\jre1.5.0_07\lib\ext folder on my computer even though I thought adding to the classpath would have been sufficient. I found this on a website forum. - A lot of people seem to have the same problem as the MySQL documentatiion (& the Apache Tomcat) doesn't mention this.

If anyone has outstanding issues regarding this mail me whenever.

Now that I have the DB running locally, I'll be testing it on my webserever.

A big thanks to all that helped.

I agree. Here's the link:
subject: MySQL Error - no driver
It's not a secret anymore!