1
I am creating a project with JDBC. When I run the code it gives the following error message:
Exception in thread "AWT-Eventqueue-0" java.lang.Runtimeexception: java.sql.Sqlexception: No suitable driver found for jdbc:mysql://localhost:3306/Car At Connectionfactory.getConnection(Connectionfactory.java:32)
I already checked if the name of my bank is correct and the connector driver is already inside my project.
Code:
import java.sql.Connection; 
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionFactory {
    public  Connection getConnection() {
        String url = "jdbc:mysql://localhost:3306/Carro";
        try {
            return DriverManager.getConnection(url, "root", "root");
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
						
Did you add the mysql driver to classpath? The error states that the driver was not found.
– user28595