文件名为db.properties

第一种: 通过ResourceBundle获取
ResourceBundle bunble = ResourceBundle.getBundle("db");
driver = bunble.getString("driver");
url = bunble.getString("url");
username = bunble.getString("username");
password = bunble.getString("password");

第二种:通过类加载器获取
// 1. 通过当前类获取类加载器   访问方式: 类型.class.getClassLoader()
ClassLoader classLoader = JDBCUtils_V3.class.getClassLoader();
// 2. 通过类类加载器获取一个输入流
InputStream is = classLoader.getResourceAsStream("db.properties");
// 3. 创建properties对象
Properties p = new Properties();
// 4. 加载输入流
p.load(is);
// 5. 获取相关参数的值
driver = p.getProperty("driver");
url = p.getProperty("url");
username = p.getProperty("username");
password = p.getProperty("password");