Home > Software design >  The import com.mysql.jdbc.Connection cannot be resolved
The import com.mysql.jdbc.Connection cannot be resolved

Time:11-14

How to solve this problem? I have downloaded and imported the "mysql-connector-java" to my build-path project, but still issue. It seems the library doesn't have the Connection class?

enter image description here

enter image description here

enter image description here

CodePudding user response:

Your referenced library looks correct but you have imported a wrong class. You should import java.sql.Connection instead of com.mysql.jdbc.Connection.

Some other important imports are as follows:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

There are hundreds of good tutorials (e.g. this) available on the internet.

  • Related