java.sql.SQLException: No suitable driver found for cj.jdbc:mysql://127.0.0.1:3306/datt?serverTimezone=GMT
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at JDBC.Test.main(Test.java:23)
代码
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Collection;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Class.forName("com.mysql.cj.jdbc.Driver");
String url="cj.jdbc:mysql://127.0.0.1:3306/datt?serverTimezone=GMT";
String use="root";
String password="123456";
try {
Collection<?> con = (Collection) DriverManager.getConnection(url, use, password);
System.out.println(con);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}