文件db.properties
包含网址,用户名和密码。
我的示例代码:
Properties DBProperties = new Properties();
Connection con = null;
DBProperties.load(
new FileInputStream(
System.getenv("Connection") + File.separator + "java" + File.separator + "properties" + File.separator + "db.properties"
)
);
logger.info("DB url: " + DBProperties.getProperty("DBURL"));
logger.info("DB username: " + DBProperties.getProperty("DBUserName"));
logger.info("DB password: " + DBProperties.getProperty("DBPassword"));