Issue
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?
src="https://i.stack.imgur.com/105xR.png" alt="enter image description here" />
Solution
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.
Answered By - Arvind Kumar Avinash
Answer Checked By - Senaida (JavaFixing Volunteer)