com.mysql.jdbc.PreparedStatement
is an internal class to the MySQL 5.x JDBC driver. Your code should not import it. It should be using the standard java.sql.PreparedStatement
class instead.
The package names have changed in the MySQL 8.x JDBC drivers, and that is what caused your code to start giving compilation errors.
Solution:
Fix your code so that it doesn't import any MySQL implementation classes1. Use the java.sql.*
and javax.sql.*
class instead.
Change your project dependencies so that the MySQL driver JAR is not a compile-time dependency. Doing that will cause any accidental source code dependencies on JDBC drivers to be flagged as compilation errors. It will also stop your IDE from making incorrect suggestions for import
statements. (My guess is that that is how the bogus import got into your codebase.)
If your code is (still) using Class.forName
to load the JDBC driver, change it to use java.sql.DriverManager
instead; see javadoc. That way you won't be burned by another change in the MySQL driver class name.
1 - Your Java code should not need to depend on MySQL-specific APIs. As far as I know, the MySQL implementation classes mirror the standard JDBC APIs, so you gain nothing by using them directly. This is not true for all vendors.