//DriverManager.getConnection("地址","账户","密码");密码一定要齐全不能有空格
import java.sql.Connection;
import java.sql.DriverManager;
public class JDBC {
public static void main(String[] args) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
// 加载 MySQL JDBC 驱动 Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("无异常,驱动成功");
//连接数据库,获得连接对象
Connection A=DriverManager.getConnection("jdbc:mysql://localhost:3306/data","root","167183");
System.out.println("数据库连接成功");
} catch (Exception e) {
e.printStackTrace();
System.out.println("驱动加载失败");
System.out.println("数据库连接失败");
}
}
}