package com.dashuo.da.common.function;
import java.io.FileInputStream;
import java.util.Properties;
public class MongoTask2 {
/**
*
* 主测试方法
*
*/
public static void main(String[] args) {
MongoTask2 jdbc = new MongoTask2();
jdbc.getParameter();
}
private static Properties dbconfig = new Properties();
private String tbl_project_data = null;
private String tbl_create_time = null;
static {
try {
// 方式一:
/*InputStream in = MongoTask2.class.getClassLoader().getResourceAsStream("value.properties");
dbconfig.load(in);*/
// 方式二
String realPath = MongoTask2.class.getClassLoader().getResource("value.properties").getPath();
FileInputStream in = new FileInputStream(realPath);
dbconfig.load(in);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* 获取配置文件db.properties中连接数据库的参数
*
*/
public void getParameter() {
tbl_project_data = dbconfig.getProperty("ProjectData");
tbl_create_time = dbconfig.getProperty("CreateTimeData");
System.out.println(" MongoDB数据表:" + tbl_project_data + " MongoDB数据创建时间表:" + tbl_create_time );
}
}