J 2 SEプロファイルの値propertiesを読み込む


util.propertiesファイル
driverClassName = oracle.jdbc.driver.OracleDriver
username = ""
password = ""
url = jdbc:oracle:thin:@192.168.1.20:1521:ora9
poolSize = 10

drivername = com.mysql.jdbc.Driver;
url2 = jdbc:mysql://localhost:3306/sqlname
プロファイルのJavaコード
/*
	 *             
	 */
	private void readConfig(){
		String path = System.getProperty("user.dir") + "\\util.properties";
		try {
			FileInputStream is = new FileInputStream(path);
			Properties pro = new Properties();
			pro.load(is);
			this.driverClassName = pro.getProperty("driverClassName");
			this.username = pro.getProperty("username");
			this.password = pro.getProperty("password");
			this.url = pro.getProperty("url");
			this.poolSize = Integer.parseInt(pro.getProperty("poolSize"));
		} catch (Exception e) {
			System.err.println("        . ");
			e.printStackTrace();
		} 
	}
を読み込む