读取.ini格式配置文件 中数据库配置的信息

public class Sql {

	public static void main(String[] args) {
		initConfig();
	}
	public  static void initConfig() {
	   InputStream inf = Sql.class.getClassLoader().getResourceAsStream("*/*/*/defalutDataSource.ini");
	   Properties properties = new Properties();
	   try {
	       properties.load(inf);
	       String classforName = properties.getProperty("defalutDataSource.connection.driver_class");
		   String sqlurl = properties.getProperty("defalutDataSource.connection.url");
		   String sqluser = properties.getProperty("defalutDataSource.connection.username");
		   String sqlpwd = properties.getProperty("defalutDataSource.connection.password");
	       System.out.println("classforName:"+classforName);
	       System.out.println("user:"+sqluser);
	       System.out.println("pwd:"+sqlpwd);
	   } catch (IOException e) {
	       System.out.println("读取配置文件失败");
	   }
	}
}

 

你可能感兴趣的:(数据库)