Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver


Advanced Search

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by: hello 123 ()
Date: November 23, 2012 03:58AM

Not sure if I have posted this topic in the correct part of the forum or whether I should've followed another topic but I couldn't seem to find the solution to my problem.

Apologies if I have posted incorrectly.

I have written the following program:

import java.sql.*;

public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "dumal";
String driver = "com.mysql.jdbc.Driver";
String userName = "u551460";
String password = "dumal";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Basically I'm doing a small test to see if my java application will connect to a mysql database that I have set up.

I have already set the PATH variable to the JDBC connector but I still continue to get this message - I can't seem to find a way around it...

Any help would be greatly appreciated!

Options: ReplyQuote


Subject Written By Posted
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver hello 123 11/23/2012 03:58AM
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Todd Farmer 11/24/2012 03:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.