How to setup connection string?
In Java we don't support named connection string, however you can pass actual connection string to DocumentStore
by calling parseConnectionString
on uninitialized store. The RavenDB client will load automatically configuration based on connection string's parameters.
try (DocumentStore store = new DocumentStore()) {
store.parseConnectionString("Url = http://localhost:8080");
store.initialize();
}
Format
RavenDB connection string format is:
Parameters | ||
---|---|---|
ApiKey | string | API key to use when accessing the server. |
Url | string | Specify where to locate the server. |
Failover | string in predefined format | Failover server definition. Read more here. |
Database or DefaultDatabase | string | Use a specific database, not the default one. Using this will also ensure that the database exists. |
Examples
The following are samples of a few RavenDB connection strings:
Url = http://ravendb.mydomain.com
// connect to a remote RavenDB instance at ravendb.mydomain.com, to the default database
Url = http://ravendb.mydomain.com;Database=Northwind
// connect to a remote RavenDB instance at ravendb.mydomain.com, to the Northwind database there