方式1:
public void connect05() throws IOException, ClassNotFoundException, SQLException {
//通过properties对象获取文件信息
Properties properties = new Properties();
properties.load(new FileInputStream("src\\Jdbc\\myjdbc\\mysql.properities"));
//获取相关的值
String user = properties.getProperty("user");
String url = properties.getProperty("url");
String driver = properties.getProperty("driver");
String password = properties.getProperty("password");
Class.forName(driver);
Connection connection = DriverManager.getConnection(url,user,password);
System.out.println(connection);
}
方式2:
使用Class.forName