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?
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.