1

Driver Not Foundjava.lang.ClassNotFoundException: com.mysql.jdbc.driver

I want to make connection between my java web application and mysql database through XAMP. I also have added external jar file which is mysql-connector-java-6.0.2.jar but still i am getting this error.

I have done this code.

public static void main(String[] args) 
{
    try {
        Class.forName("com.mysql.jdbc.driver");
        System.out.println("Driver has been found..");
    } catch (ClassNotFoundException ex) {
        System.out.println("Driver Not Found"+ex);
    }

    String url="jdbc:mysql://localhost/hms";
    String user="root";
    String password="";

    Connection con=null;

    try {
        con=DriverManager.getConnection(url, user, password);
        System.out.println("Driver is successfully loaded.");
    } catch (SQLException ex) {
        System.out.println("Something is not good.");
    }
}
1

2 Answers 2

3

Class names in Java are case-sensitive. You need to capitalize the "D" in "driver":

Class.forName("com.mysql.jdbc.Driver");
// Here ----------------------^
Sign up to request clarification or add additional context in comments.

Comments

2

You should write this because because java is Case-Sensitive

public static void main(String[] args) 
{
    try {
        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver has been found..");
    } catch (ClassNotFoundException ex) {
        System.out.println("Driver Not Found"+ex);
    }

    String url="jdbc:mysql://localhost/hms";
    String user="root";
    String password="";

    Connection con=null;

    try {
        con=DriverManager.getConnection(url, user, password);
        System.out.println("Driver is successfully loaded.");
    } catch (SQLException ex) {
        System.out.println("Something is not good.");
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.