0

I know this has been asked before, but in my case, adding the library (Rightclickling project>Buildpath>Configure buildpath>Add External JARs> Select JAR) hasn't worked and I still keep receiving the error.

Here's my code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Client {
    public static void main(String[] args) throws Exception
    {
            getConnection();
    }

    public static Connection getConnection() throws Exception
    {
        try
        {
            String driver = "com.mysql.jbdc.Driver";
            String url = "jdbc:mysql://localhost:3306/testdb";
            String username = "root";
            String password = "admin";

            Class.forName(driver);

            //Creating a variable for the connection called "con"
            Connection con = DriverManager.getConnection(url, username, password);

            System.out.println("Connected");
            return con;

        } catch(Exception e){System.out.println(e);}

        return null;
    }
}

And "mysql-connector-java-52.40-bin.jar" appears under "Referenced Libraries".

Any help would be appreciated.

1
  • add your full error message to your question Commented Dec 5, 2016 at 1:03

1 Answer 1

2

Nevermind, I'm an idiot. It has to be "jdbc" instead of "jbdc". Carry on.

Sign up to request clarification or add additional context in comments.

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.