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.