Operations: How to Get Connection String

You can get connection strings by using GetConnectionStringsOperation.

Syntax

public GetConnectionStringsOperation()
public GetConnectionStringsOperation(String connectionStringName, ConnectionStringType type)
Parameters
connectionStringName String Connection string name
type ConnectionStringType Connection string type: RAVEN or SQL
Return Value
sqlConnectionStrings Map<String, SqlConnectionString> Map which maps sql connection string name to definition
ravenConnectionStrings Map<String, RavenConnectionString> Map which maps raven connection string name to definition

RavenConnectionString

public class RavenConnectionString extends ConnectionString {
    private String database; // target database name
    private String[] topologyDiscoveryUrls; // list of server urls

    public ConnectionStringType getType() {
        return ConnectionStringType.RAVEN;
    }

    // getters and setters
}

SqlConnectionString

public class SqlConnectionString extends ConnectionString {
    private String connectionString;
    private String factoryName;

    public ConnectionStringType getType() {
        return ConnectionStringType.SQL;
    }

    // getters and setters
}

ConnectionString

public class ConnectionString {
    private String name; // name of connection string

    // getters and setters
}

Example - Get all Connection Strings

GetConnectionStringsOperation operation = new GetConnectionStringsOperation();
GetConnectionStringsResult connectionStrings = store.maintenance().send(operation);
Map<String, SqlConnectionString> sqlConnectionStrings =
    connectionStrings.getSqlConnectionStrings();
Map<String, RavenConnectionString> ravenConnectionStrings =
    connectionStrings.getRavenConnectionStrings();

Example - Get Connection String By Name and Type

GetConnectionStringsOperation operation = new GetConnectionStringsOperation(
    "local_mysql", ConnectionStringType.SQL);
GetConnectionStringsResult connectionStrings = store.maintenance().send(operation);
Map<String, SqlConnectionString> sqlConnectionStrings =
    connectionStrings.getSqlConnectionStrings();
SqlConnectionString mysqlConnectionString = sqlConnectionStrings.get("local_mysql");