overload file database properties with any passed on URL line
do not store password etc
322318
public void setURLProperties(HsqlProperties p) {

        if (p != null) {
            for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) {
                String   propertyName = (String) e.nextElement();
                Object[] row          = (Object[]) meta.get(propertyName);

                if (row != null
                        && (db_readonly.equals(propertyName)
                            || ((Integer) row[indexType]).intValue()
                               == SET_PROPERTY)) {

                    // can add error checking with defaults
                    setProperty(propertyName, p.getProperty(propertyName));
                }
            }
        }
    }
660535
private void doGetDatasources() throws PageException {

	Map ds = config.getDataSourcesAsMap();
	Iterator it = ds.keySet().iterator();
	lucee.runtime.type.Query qry = new QueryImpl(new String[] { "name", "host", "classname", "bundleName", "bundleVersion", "dsn", "DsnTranslated", "database", "port",
		"timezone", "username", "password", "passwordEncrypted", "readonly", "grant", "drop", "create", "revoke", "alter", "select", "delete", "update", "insert",
		"connectionLimit", "openConnections", "connectionTimeout", "clob", "blob", "validate", "storage", "customSettings", "metaCacheTimeout" }, ds.size(), "query");

	int row = 0;

	while (it.hasNext()) {
	    Object key = it.next();
	    DataSource d = (DataSource) ds.get(key);
	    row++;

	    qry.setAt(KeyConstants._name, row, key);
	    qry.setAt(KeyConstants._host, row, d.getHost());
	    qry.setAt("classname", row, d.getClassDefinition().getClassName());
	    qry.setAt("bundleName", row, d.getClassDefinition().getName());
	    qry.setAt("bundleVersion", row, d.getClassDefinition().getVersionAsString());
	    qry.setAt("dsn", row, d.getDsnOriginal());
	    qry.setAt("database", row, d.getDatabase());
	    qry.setAt(KeyConstants._port, row, d.getPort() < 1 ? "" : Caster.toString(d.getPort()));
	    qry.setAt("dsnTranslated", row, d.getDsnTranslated());
	    qry.setAt("timezone", row, toStringTimeZone(d.getTimeZone()));
	    qry.setAt(KeyConstants._password, row, d.getPassword());

	    qry.setAt("passwordEncrypted", row, ConfigWebUtil.encrypt(d.getPassword()));
	    qry.setAt(KeyConstants._username, row, d.getUsername());
	    qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(d.isReadOnly()));
	    qry.setAt(KeyConstants._select, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT)));
	    qry.setAt(KeyConstants._delete, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE)));
	    qry.setAt(KeyConstants._update, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE)));
	    qry.setAt(KeyConstants._create, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE)));
	    qry.setAt(KeyConstants._insert, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
	    qry.setAt(KeyConstants._drop, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP)));
	    qry.setAt(KeyConstants._grant, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT)));
	    qry.setAt(KeyConstants._revoke, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE)));
	    qry.setAt(KeyConstants._alter, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER)));
	    int oc = config.getDatasourceConnectionPool().openConnections(key.toString());
	    qry.setAt("openConnections", row, oc < 0 ? 0 : oc);
	    qry.setAt("connectionLimit", row, d.getConnectionLimit() < 1 ? "" : Caster.toString(d.getConnectionLimit()));
	    qry.setAt("connectionTimeout", row, d.getConnectionTimeout() < 1 ? "" : Caster.toString(d.getConnectionTimeout()));
	    qry.setAt("customSettings", row, d.getCustoms());
	    qry.setAt("blob", row, Boolean.valueOf(d.isBlob()));
	    qry.setAt("clob", row, Boolean.valueOf(d.isClob()));
	    qry.setAt("validate", row, Boolean.valueOf(d.validate()));
	    qry.setAt("storage", row, Boolean.valueOf(d.isStorage()));
	    qry.setAt("metaCacheTimeout", row, Caster.toDouble(d.getMetaCacheTimeout()));

	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
1024842
public static void loadPropertiesFile(final String filenameOrUrl)
    {
        final Properties properties = new Properties(System.getProperties());
        System.getProperties().forEach(properties::put);

        final URL resource = ClassLoader.getSystemClassLoader().getResource(filenameOrUrl);
        if (null != resource)
        {
            try (InputStream in = resource.openStream())
            {
                properties.load(in);
            }
            catch (final Exception ignore)
            {
            }
        }

        final File file = new File(filenameOrUrl);
        if (file.exists())
        {
            try (FileInputStream in = new FileInputStream(file))
            {
                properties.load(in);
            }
            catch (final Exception ignore)
            {
            }
        }

        try (InputStream in = new URL(filenameOrUrl).openStream())
        {
            properties.load(in);
        }
        catch (final Exception ignore)
        {
        }

        System.setProperties(properties);
    }
154741
function buildLoginUrl(connectionConfig)
{
  var queryParams =
  [
    { name: 'warehouse',    value: connectionConfig.getWarehouse() },
    { name: 'databaseName', value: connectionConfig.getDatabase() },
    { name: 'schemaName',   value: connectionConfig.getSchema() },
    { name: 'roleName',     value: connectionConfig.getRole() }
  ];

  var queryStringObject = {};
  for (var index = 0, length = queryParams.length; index < length; index++)
  {
    var queryParam = queryParams[index];
    if (Util.string.isNotNullOrEmpty(queryParam.value))
    {
      queryStringObject[queryParam.name] = queryParam.value;
    }
  }

  return Url.format(
  {
    pathname : '/session/v1/login-request',
    search   : QueryString.stringify(queryStringObject)
  });
}
250942
protected void readDatabaseConfig() {

        m_databaseKeys = new ArrayList<String>();
        m_databaseProperties = new HashMap<String, Properties>();

        FileInputStream input = null;
        File childResource = null;

        List<String> databaseKeys = new ArrayList<String>();
        Map<String, Properties> databaseProperties = new HashMap<String, Properties>();

        try {
            File databaseSetupFolder = new File(m_webAppRfsPath + FOLDER_SETUP + FOLDER_DATABASE);

            File[] childResources = databaseSetupFolder.listFiles();

            // collect all possible db configurations
            if (childResources != null) {
                for (int i = 0; i < childResources.length; i++) {
                    childResource = childResources[i];
                    if (childResource.exists() && childResource.isDirectory() && childResource.canRead()) {
                        databaseKeys.add(childResource.getName().trim());
                    }
                }
            }

            // create the properties with all possible configurations
            if (databaseSetupFolder.exists()) {
                for (String key : databaseKeys) {
                    String dbDir = m_webAppRfsPath + CmsSetupBean.FOLDER_SETUP + "database" + File.separatorChar + key;
                    String configPath = dbDir + File.separatorChar + "database.properties";
                    try {
                        input = new FileInputStream(new File(configPath));
                        Properties databaseProps = new Properties();
                        databaseProps.load(input);
                        databaseProperties.put(key, databaseProps);
                    } catch (Exception e) {
                        System.err.println(e.toString());
                        e.printStackTrace(System.err);
                        continue;
                    }
                }
            }

            // add the properties and the keys to the memeber variables if all needed files exist
            if (childResources != null) {
                for (int i = 0; i < childResources.length; i++) {
                    childResource = childResources[i];
                    if (childResource.exists() && childResource.isDirectory() && childResource.canRead()) {
                        String dataBasekey = childResource.getName().trim();
                        Properties props = databaseProperties.get(dataBasekey);
                        if (checkFilesExists(REQUIRED_SQL_DB_SETUP_FILES, childResource)) {
                            m_databaseKeys.add(childResource.getName().trim());
                            m_databaseProperties.put(dataBasekey, props);
                        }
                    }
                }
            }
        } catch (Exception e) {
            System.err.println(e.toString());
            e.printStackTrace(System.err);
        } finally {
            try {
                if (input != null) {
                    input.close();
                }
            } catch (Exception e) {
                // noop
            }
        }
    }
1333900
void open() {

        initParams();

        int state = properties.getDBModified();

        switch (state) {

            case HsqlDatabaseProperties.FILES_MODIFIED :
                deleteNewAndOldFiles();
                restoreBackup();
                processScript();
                processDataFile();
                processLog();
                close(false);

                if (cache != null) {
                    cache.open(filesReadOnly);
                }

                reopenAllTextCaches();
                break;

            case HsqlDatabaseProperties.FILES_NEW :
                try {
                    deleteBackup();
                    backupData();
                    renameNewBackup();
                    renameNewScript();
                    deleteLog();
                    properties.setDBModified(
                        HsqlDatabaseProperties.FILES_NOT_MODIFIED);
                } catch (IOException e) {
                    database.logger.appLog.logContext(e, null);
                }

            // continue as non-modified files
            // $FALL-THROUGH$
            case HsqlDatabaseProperties.FILES_NOT_MODIFIED :

                /**
                 * if startup is after a SHUTDOWN SCRIPT and there are CACHED
                 * or TEXT tables, perform a checkpoint so that the .script
                 * file no longer contains CACHED or TEXT table rows.
                 */
                processScript();

                if (isAnyCacheModified()) {
                    properties.setDBModified(
                        HsqlDatabaseProperties.FILES_MODIFIED);
                    close(false);

                    if (cache != null) {
                        cache.open(filesReadOnly);
                    }

                    reopenAllTextCaches();
                }
                break;
        }

        openLog();

        if (!filesReadOnly) {
            properties.setDBModified(HsqlDatabaseProperties.FILES_MODIFIED);
        }
    }
645994
private void initParameters() throws FileNotFoundException {
        InputStream fileStream;
        if (new File(parameterfile).exists()) {
            logger.info("Try reading properties directly from {}.", parameterfile);
            fileStream = new FileInputStream(new File(parameterfile));
        } else {
            logger.info("Try reading properties from Resources");
            fileStream = this.getClass().getClassLoader().getResourceAsStream(parameterfile);
        }

        Properties props = new Properties();
        try {
            props.load(fileStream);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        DATABASE_DIRECTORY = props.getProperty("DATABASE_DIRECTORY");
        BUCKET_MEMORY = parseSize(props.getProperty("BUCKET_MEMORY", "1G"));
        MEMORY_CHUNK = (int) parseSize(props.getProperty("MEMORY_CHUNK", "10K"));
        MAX_MEMORY_PER_BUCKET = parseSize(props.getProperty("MAX_MEMORY_PER_BUCKET", "100M"));
        SYNC_CHUNK_SIZE = parseSize(props.getProperty("SYNC_CHUNK_SIZE", "2M"));
        FILE_CHUNK_SIZE = parseSize(props.getProperty("FILE_CHUNK_SIZE", "32K"));
        // determine exact index size
        FILE_CHUNK_SIZE = FILE_CHUNK_SIZE - FILE_CHUNK_SIZE % prototype.getSize();
        NUMBER_OF_SYNCHRONIZER_THREADS = Integer.valueOf(props.getProperty("NUMBER_OF_SYNCHRONIZER_THREADS", "1"));
        MAX_BUCKET_STORAGE_TIME = Long.valueOf(props.getProperty("MAX_BUCKET_STORAGE_TIME", "84000000"));
        MIN_ELEMENT_IN_BUCKET_BEFORE_SYNC = Integer
                .valueOf(props.getProperty("MIN_ELEMENT_IN_BUCKET_BEFORE_SYNC", "1"));
        HEADER_FILE_LOCK_RETRY = Integer.valueOf(props.getProperty("HEADER_FILE_LOCK_RETRY", "100"));

        INITIAL_FILE_SIZE = (int) parseSize(props.getProperty("INITIAL_FILE_SIZE", "16M"));
        INITIAL_INCREMENT_SIZE = (int) parseSize(props.getProperty("INITIAL_INCREMENT_SIZE", "16M"));
        configToLogInfo();
    }
1194278
private static synchronized Database getDatabaseObject(String type,
            String path, HsqlProperties props) {

        Database db;
        String   key = path;
        // A VoltDB extension to work around ENG-6044
        /* disable 13 lines ...
        HashMap  databaseMap;

        if (type == DatabaseURL.S_FILE) {
            databaseMap = fileDatabaseMap;
            key         = filePathToKey(path);
        } else if (type == DatabaseURL.S_RES) {
            databaseMap = resDatabaseMap;
        } else if (type == DatabaseURL.S_MEM) {
            databaseMap = memDatabaseMap;
        } else {
            throw Error.runtimeError(ErrorCode.U_S0500,
                                     "DatabaseManager.getDatabaseObject");
        }
           ... disabled 13 lines */

        assert (type == DatabaseURL.S_MEM);
        java.util.HashMap<String, Database> databaseMap = memDatabaseMap;
        // End of VoltDB extension

        db = (Database) databaseMap.get(key);

        if (db == null) {
            db            = new Database(type, path, type + key, props);
            db.databaseID = dbIDCounter;

            databaseIDMap.put(dbIDCounter, db);

            dbIDCounter++;

            databaseMap.put(key, db);
        }

        return db;
    }
911101
public void setDatasourceParams(JdbcDatabase database, com.mysql.jdbc.jdbc2.optional.MysqlDataSource dataSource)
    {
        String strURL = database.getProperty(SQLParams.JDBC_URL_PARAM);
        if ((strURL == null) || (strURL.length() == 0))
            strURL = database.getProperty(SQLParams.DEFAULT_JDBC_URL_PARAM);    // Default
        String strServer = database.getProperty(SQLParams.DB_SERVER_PARAM);
        if ((strServer == null) || (strServer.length() == 0))
            strServer = database.getProperty(SQLParams.DEFAULT_DB_SERVER_PARAM);    // Default
        if ((strServer == null) || (strServer.length() == 0))
            strServer = "localhost"; //this.getProperty(DBParams.SERVER);    // ??       
        String strDatabaseName = database.getDatabaseName(true);
        if (strURL != null)
        {
            if (strServer != null)
                strURL = Utility.replace(strURL, "{dbserver}", strServer);
            strURL = Utility.replace(strURL, "{dbname}", strDatabaseName);
        }
        String strUsername = database.getProperty(SQLParams.USERNAME_PARAM);
        if ((strUsername == null) || (strUsername.length() == 0))
            strUsername = database.getProperty(SQLParams.DEFAULT_USERNAME_PARAM); // Default
        String strPassword = database.getProperty(SQLParams.PASSWORD_PARAM);
        if ((strPassword == null) || (strPassword.length() == 0))
            strPassword = database.getProperty(SQLParams.DEFAULT_PASSWORD_PARAM); // Default

        dataSource.setDatabaseName(strDatabaseName);
        if (strServer != null)
            dataSource.setServerName(strServer);
        else
            dataSource.setURL(strURL);
        dataSource.setUser (strUsername);
        dataSource.setPassword (strPassword);
    }
1206970
private Properties loadOverrides(File baseDir, Properties properties) throws IOException {
        return loadProperties(baseDir, properties, "override", true);
    }
718501
public synchronized void persistProperties() throws IOException {
        beginPersistence();

        // Read the properties file into memory
        // Shouldn't be so bad - it's a small file
        List<String> content = readFile(propertiesFile);

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(propertiesFile), StandardCharsets.UTF_8));

        try {
            for (String line : content) {
                String trimmed = line.trim();
                if (trimmed.length() == 0) {
                    bw.newLine();
                } else {
                    Matcher matcher = PROPERTY_PATTERN.matcher(trimmed);
                    if (matcher.matches()) {
                        final String key = cleanKey(matcher.group(1));
                        if (toSave.containsKey(key) || toSave.containsKey(key + DISABLE_SUFFIX_KEY)) {
                            writeProperty(bw, key, matcher.group(2));
                            toSave.remove(key);
                            toSave.remove(key + DISABLE_SUFFIX_KEY);
                        } else if (trimmed.startsWith(COMMENT_PREFIX)) {
                            // disabled user
                            write(bw, line, true);
                        }
                    } else {
                        write(bw, line, true);
                    }
                }
            }

            endPersistence(bw);
        } finally {
            safeClose(bw);
        }
    }
894601
function (DB_name, name, onDone, prefix) {

	//LOG.warn('init ' + DB_name + ' collection: ' + name, 'SR.DB');

	if (l_DBclient.hasOwnProperty(DB_name) === false) {
		LOG.error('DBclient not init or authenticated for DB [' + DB_name + ']', 'SR.DB');
		return UTIL.safeCall(onDone, false);
	}

	// check if already init
	if (l_getCollection(name, undefined, DB_name) !== undefined) {
		LOG.warn('DB [' + DB_name + '] collection [' + name + '] already loaded', 'SR.DB');
		LOG.warn('please check if different codes are using the same collection names', 'SR.DB');
		// NOTE: we assume double declaration of collection name is ok
		return UTIL.safeCall(onDone, true);
	}

	// build collection name to prefix with server name or a specified prefix
	var collection_name = (prefix || SR.Settings.SERVER_INFO.name) + ':' + name;

	// original simple version
	//var collection_name = name;

	l_DBclient[DB_name].collection(collection_name,
		function (err, collection) {
			if (err) {
				LOG.error(err, 'SR.DB');
				LOG.error('init DB [' + DB_name + ' ] collection [' + collection_name + '] error', 'SR.DB');
				UTIL.safeCall(onDone, false);
			} else {
				// store each name as a collection entry in collection object
				// collection name, instance(conn) , cache (idx by _id)
				var msg = 'init DB [' + DB_name + '] collection [' + collection_name + '] success';
				LOG.debug(msg, 'SR.DB');
				if (l_clts.hasOwnProperty(DB_name) === false) {
					l_clts[DB_name] = {};
				}

				// store collection instance into a two-level map
				l_clts[DB_name][name] = collection;

				// attach entity list to collection (for object caching)
				l_clts[DB_name][name].cache = {};

				UTIL.safeCall(onDone, true);
			}
		}
	);
}
456363
def file_set_properties(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/setProperties' % object_id, input_params, always_retry=always_retry, **kwargs)
1146816
def db_use_local_file(self, arg, filename=None):
        '''  '''
        # interactive = False  # Never used
        if filename is None:
            # interactive = True  # Never used
            filename = raw_input('Enter the filename of the local SQLLite '
                                 'database you would like to use '
                                 '[default=participants.db]: ')
            if filename == '':
                filename = 'participants.db'
        base_url = "sqlite:///" + filename
        self.config.set("Database Parameters", "database_url", base_url)
        print "Updated database setting (database_url): \n\t", \
        self.config.get("Database Parameters", "database_url")
        if self.server.is_server_running() == 'yes':
            self.server_restart()
1007661
function ( uri ) {
		var obj    = {},
		    parsed = {};

		if ( uri === undefined ) {
			uri = !server ? location.href : "";
		}

		if ( !server ) {
			obj = document.createElement( "a" );
			obj.href = uri;
		}
		else {
			obj = url.parse( uri );
		}

		if ( server ) {
			utility.iterate( obj, function ( v, k ) {
				if ( v === null ) {
					obj[k] = undefined;
				}
			});
		}

		parsed = {
			auth     : server ? null : regex.auth.exec( uri ),
			protocol : obj.protocol || "http:",
			hostname : obj.hostname || "localhost",
			port     : obj.port ? number.parse( obj.port, 10 ) : "",
			pathname : obj.pathname,
			search   : obj.search   || "",
			hash     : obj.hash     || "",
			host     : obj.host     || "localhost"
		};

		// 'cause IE is ... IE; required for data.batch()
		if ( client.ie ) {
			if ( parsed.protocol === ":" ) {
				parsed.protocol = location.protocol;
			}

			if ( string.isEmpty( parsed.hostname ) ) {
				parsed.hostname = location.hostname;
			}

			if ( string.isEmpty( parsed.host ) ) {
				parsed.host = location.host;
			}

			if ( parsed.pathname.charAt( 0 ) !== "/" ) {
				parsed.pathname = "/" + parsed.pathname;
			}
		}

		parsed.auth  = obj.auth || ( parsed.auth === null ? "" : parsed.auth[1] );
		parsed.href  = obj.href || ( parsed.protocol + "//" + ( string.isEmpty( parsed.auth ) ? "" : parsed.auth + "@" ) + parsed.host + parsed.pathname + parsed.search + parsed.hash );
		parsed.path  = obj.path || parsed.pathname + parsed.search;
		parsed.query = utility.queryString( null, parsed.search );

		return parsed;
	}
107995
def load(path: str) -> "Store":
        """"""
        # load source (decrypting if necessary)
        if _gpg.is_encrypted(path):
            src_bytes = _gpg.decrypt(path)
        else:
            src_bytes = open(path, "rb").read()
        src = src_bytes.decode("utf-8")

        # parse database source
        ext = _gpg.unencrypted_ext(path)
        assert ext not in [
            ".yml",
            ".yaml",
        ], "YAML support was removed in version 0.12.0"
        entries = _parse_entries(src)

        return Store(path, entries)
309072
private static Properties load() {
		Properties properties = new Properties();

		String file = System.getProperty(CONFIGURATION_PROPERTY);
		try {
			if (file != null) {
				InputStream stream;
				if (URL_DETECTION_PATTERN.matcher(file).matches()) {
					stream = new URL(file).openStream();
				} else {
					stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
					if (stream == null) {
						stream = new FileInputStream(file);
					}
				}
				load(properties, stream);
			} else {
				InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_CONFIGURATION_FILE);
				if (stream != null) {
					load(properties, stream);
				}
			}
		} catch (IOException ex) {
			InternalLogger.log(Level.ERROR, "Failed loading configuration from '" + file + "'");
		}

		for (Object key : new ArrayList<Object>(System.getProperties().keySet())) {
			String name = (String) key;
			if (name.startsWith(PROPERTIES_PREFIX)) {
				properties.put(name.substring(PROPERTIES_PREFIX.length()), System.getProperty(name));
			}
		}

		for (Entry<Object, Object> entry : properties.entrySet()) {
			String value = (String) entry.getValue();
			if (value.indexOf('{') != -1) {
				value = resolve(value, EnvironmentVariableResolver.INSTANCE);
				value = resolve(value, SystemPropertyResolver.INSTANCE);
				properties.put(entry.getKey(), value);
			}
		}

		return properties;
	}