线程“主”中的异常java.sql.SQLException:未找到合适的驱动程序

时间:2019-03-26 23:43:15

标签: java jdbc

为什么我有这个问题?

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/esame/useJDBCCompliantTimezoneShift=true;useLegacyDatetimeCode=false;serverTimezone=UTC;

这是我的代码:     导入java.sql。*;     公共类DBConnector {

private final String NOME_DRIVER = "com.mysql.cj.jdbc.Driver";
private String url;
private String user;
private String password;
private Connection conn;
private Query qr;

    public DBConnector(String url, String user, String password) throws ClassNotFoundException, SQLException {
        setUrl(url); setUser(user); setPassword(password);
        Class.forName(getNomeDriver());
        setConn(DriverManager.getConnection(getUrl(), getUser(), getPassword()));

    }

public String getNomeDriver() {
    return this.NOME_DRIVER;
}    
}

我添加了外部jar以在Eclipse中构建路径。

0 个答案:

没有答案