public static Connection getConn() { if (conn == null) { String url = MyUtil.getConfigValue("jdbc.properties", "jdbc.system.url"); String userName = MyUtil.getConfigValue("jdbc.properties", "jdbc.system.username"); String userPassword = MyUtil.getConfigValue("jdbc.properties", "jdbc.system.password"); try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection(url, userName, userPassword); } catch (Exception e) { e.printStackTrace(); } } return conn; }
public void setMyLocations(Resource[] myLocations) { Properties[] ppa = new Properties[myLocations.length]; MyUtil mu = MyUtil.getInstance(); int ppaIndex = 0; for (Resource rs : myLocations) { try { Properties pp = new Properties(); pp.load(rs.getInputStream()); List<String> removeKey = new ArrayList<String>(); String key = ""; for (Iterator<Object> it = pp.keySet().iterator(); it.hasNext(); ) { key = it.next().toString(); if (null != pp.get(key + "/") && mu.equals(File.separator, "/")) { cmap.put(key, pp.get(key + "/").toString()); removeKey.add(key); } else { cmap.put(key, pp.get(key).toString()); } } if (removeKey.size() > 0) { for (String rk : removeKey) { if (mu.equals(File.separator, "/")) { // linux pp.setProperty(rk, pp.getProperty(rk + "/")); } } OutputStream out = new FileOutputStream(rs.getFile()); pp.store(out, "xxx"); out.close(); } ppa[ppaIndex] = pp; ppaIndex++; } catch (IOException e) { log.error("load Evn error: ", e); } } this.setPropertiesArray(ppa); this.setLocalOverride(true); // 覆盖以前的配�? this.setLocations(myLocations); }