//第一种方式
Properties prop= new Properties();
//读取文件 通过类加载读取
InputStream is = JDBCUtils.class.getClassLoader().getResourceAsStream("data.properties");
prop.load(is);
String driverClass = prop.getProperty("driverClass");
String url = prop.getProperty("url");
String username = prop.getProperty("username");
String password = prop.getProperty("password");
//第二种方式
Properties properties = new Properties();
// 读取属性文件:使用Java中Properties的对象.
InputStream is = new FileInputStream("src/jdbc.properties");
properties = new Properties();
properties.load(is);
String driverClass = properties.getProperty("driverClass");
String url = properties.getProperty("url");
String username = properties.getProperty("username");
String password = properties.getProperty("password");