以前全是这么做的,不过是个配置文件不是xml
道理应该一样    private void init() {
        FileInputStream is=null;
        try{
            if(System.getProperty("file.separator").equals("/"))
                is= new FileInputStream("./config/db.properties");
            else
                is= new FileInputStream(".\\config\\db.properties");
        }catch(FileNotFoundException e){
        System.out.println("File db.properties not found");
        }
        Properties dbProps = new Properties();
        try {
            dbProps.load(is);
        }
        catch (Exception e) {
            System.err.println("Can't read the properties file. " +
            "Make sure db.properties is in the CLASSPATH");
            return;
        }
        logFile = dbProps.getProperty("logFile", "DBConnectionManager.log");
        loadDrivers(dbProps);
        createPools(dbProps);
  }