public static String mysql_url;
public static String mysql_uname;
public static String mysql_passwd;
static{
Properties properties = new Properties();
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("/org/hzy/config/datasource.properties");
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
mysql_url=properties.getProperty("url");
mysql_uname=properties.getProperty("uname");
mysql_passwd=properties.getProperty("passworld");
System.out.print(properties.getProperty("initialContextfactory"));
System.out.print(properties.getProperty("providerURL"));
System.out.print(properties.getProperty("dataSource"));
}
getClass().getClassLoader().//默認的是src文件夾下
getClass()//表示當前包中的文件