I've already checked all the other answers and I've not find a correct answer.
I've a servlet that wants to insert data into a MySQL DB through a Model (InterazioneDB.java), so in the constructor I put this. On the PC I've downloaded MySQL Workbench for creating the databases
InterazioneDB(){
try {
//Creea il collegamento con il DB
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/sitofoto?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC",
"root", "password"
); // for MySQL only
} catch(SQLException ex) {
ex.printStackTrace();
}
}
When I create the object I get the error: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/sitofoto?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
I have the driver (mysql-connector-java-8.0.19.jar) in lib folder inside WEB-INF
I've already tried to remove, reinstall it again and with Class.forName("com.mysql.jdbc.Driver");
even though it's deprecated.
I did that yesterday (and I didn't change that part of code) and it worked, so I don't know what to do.