I'm 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 / at ConnectionFactory.getConnection (ConnectionFactory.java:32)
I've already checked if my bank name 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);
}
}
}