javajava-10mysql-8.0rowset

JAVA 10 - java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/ error


I know it's an old question but the case is different here. It seems to be a bug at JAVA 10 or MySQLConnector/J 8.0.12 jar classes.

The same projects (lots of them, not just one) that worked fine with JAVA 8 and MySQLConnector/J 5.1.39, which I used before, now don't work after I updated my system.

But the error appears only with RowSet. With DriverManager/Connection/ResultSet, explicitly used, it works pretty fine with the same url, url-parameters and MySQL driver.

I've tried to redundantly use Class.forName("")... as well as variations of the url parameters, but nothing works when I use RowSet. The same java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/scheme1?verifyServerCertificate=false&useSSL=true is thrown again and again.

Why the same code works with Java 8 and not Java 10 ?

try {
        RowSet rowSet = RowSetProvider.newFactory().createCachedRowSet();
        String url = "jdbc:mysql://localhost:3306/scheme1?verifyServerCertificate=false&useSSL=true";
        rowSet.setUrl(url);
        rowSet.setUsername("root");
        rowSet.setPassword("root");
        rowSet.setCommand("select * from client");
        rowSet.execute();
        while(rowSet.next()) {
            System.out.println(rowSet.getInt(1)+" "+rowSet.getString(2));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }enter image description here

(See pictures with the error).

If someone know the problem and a solution please help. I'd like to keep using Java 10.

Daniel Pinheiro

danielpm1982@gmail.com

enter image description here

enter image description here


Solution

  • mysql-connector.jar is ment for JAVA 8 You need to wait till MySQL rollout the connector for JAVA 10 or downgrade to JAVA 8.