I am a beginner in java and am trying to connect it with a database I am having this problem java.sql.SQLException
This is my code
import java.sql.*;
public class Driver {
public static void main(String[] args) {
try {
//1. Get a connection to database
Class.forName("com.mysql.cj.jdbc.Driver");
Connection myConn = DriverManager.getConnection("jdbc.mysql://localhost:3306/demo", "root"," ");
//2.Create a statement
Statement myStat = myConn.createStatement();
//3.Execute SQL query
ResultSet myRs = myStat.executeQuery("select * from employees");
//4.Process the result set
while(myRs.next())
{
System.out.println(myRs.getString("last_name")+ ","+myRs.getString("first_name"));
}
}catch (Exception exc) {
exc.printStackTrace();
}
}
} and this is the error
java.sql.SQLException: No suitable driver found for
jdbc.mysql://localhost:3306/demo
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at jdbcdemo.Driver.main(Driver.java:12)
I had already applied the mysql-connector-java version.jar in the library but it's not working .can someone help me?