源码
@Test
public void getConnection() throws Exception {
//1 读取配置文件中的4个基本信息
InputStream is = JDBC_Utils.class.getClassLoader().getResourceAsStream("../../jdbc.properties");
Properties pros = new Properties();
pros.load(is);
String user = pros.getProperty("user");
String password = pros.getProperty("password");
String url = pros.getProperty("url");
String driverClass = pros.getProperty("driverClass");
System.out.println("----");
System.out.println("driverClass = " + driverClass);
System.out.println("url = " + url);
//2 加载驱动
Class.forName(driverClass);
//3 获取连接
Connection connection = DriverManager.getConnection(url, user, password);
System.out.println(connection);
}
出现错误
、、、、、、、、、
之前的通代码文件也出现了错误