It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes Error: ClassNotFoundException: com.jdbc.mysql.jdbcDriver, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Error: ClassNotFoundException: com.jdbc.mysql.jdbcDriver,"No suitable driver" " Watch "Error: ClassNotFoundException: com.jdbc.mysql.jdbcDriver,"No suitable driver" " New topic

Error: ClassNotFoundException: com.jdbc.mysql.jdbcDriver,"No suitable driver"

p Walsh

Joined: Nov 13, 2003
Posts: 14
I am relativly new to java, I only been programiming for about 4/5 months,
I am trying to test a simple connection to a mysql database but I keep getting the same error.
I downloaded and saved the file mysql-connector-java-3.0.10-stable-bin.jar to following directory on c ..
I then changed the classpath to reflect the following
When I run the following code i continue to receive the error
C:\>java TestQuery
ClassNotFoundException: com.jdbc.mysql.jdbcDriver
Trying to connect...
SQLException: No suitable driver

import java.sql.*;
public class TestQuery {
public TestQuery () {
public static void main(String args[]) {
String url="jdbc://localhost/publish";
Connection con;
String query = "SELECT * FROM book";
Statement stmt;
try {
catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
try {
System.out.println("Trying to connect...");
con = DriverManager.getConnection (url, "publish", "wrox");
stmt = con.createStatement();
ResultSet result = stmt.executeQuery(query);
while ( {
String name = result.getString(1) + " " + result.getString(2);
catch(SQLException ex) {
System.err.print("SQLException: ");

Can you please advise,
Do i need to import a packae and if so what package:
The tables have been set up and the database "publish" with the username and password have also been set up properly.
The strange thing is that I wrote a jsp file to update this database and it worked ok , so this leads me to belive that I have properly referenced somEthing in the above code.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Your database URL doesn't look correct. "No suitable driver" means the DRiverManager couldn't find a registered Driver that accepts your database URL. As long as the driver was found (which it should be, since you don't see that error), feeding the correct database URL should match it to the correct DRiver.
Try: jdbc:mysql://localhost/publish
p Walsh

Joined: Nov 13, 2003
Posts: 14
Thansk for the advice,
The problem was I left "mysql" out of the url string.
I've now made the nesscary changes and all is fine.
Thanks again.
I agree. Here's the link:
subject: Error: ClassNotFoundException: com.jdbc.mysql.jdbcDriver,"No suitable driver"
It's not a secret anymore!