Skip to content

Commit bb21387

Browse files
committed
Set connection string styles to ini
1 parent dc91f65 commit bb21387

File tree

1 file changed

+18
-18
lines changed
  • docs/reference/content/reference/connecting

1 file changed

+18
-18
lines changed

docs/reference/content/reference/connecting/index.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,58 @@ General information about connecting to MongoDB servers.
1313

1414
### Connection String
1515

16-
The [connection string](http://docs.mongodb.org/manual/reference/connection-string/) is the simplest way to connect to one or more
16+
The [connection string](http://docs.mongodb.org/manual/reference/connection-string/) is the simplest way to connect to one or more
1717
MongoDB servers. A connection string mostly follows [RFC 3986](http://tools.ietf.org/html/rfc3986) with the exception of the domain name.
18-
For MongoDB, it is possible to list multiple domain names separated by a comma. Below are some example connection strings.
18+
For MongoDB, it is possible to list multiple domain names separated by a comma. Below are some example connection strings.
1919

2020

2121
- For a standalone mongod, mongos, or a direct connection to a member of a replica set:
22-
23-
```
22+
23+
```ini
2424
mongodb://host:27017
2525
```
2626

2727
- To connect to multiple mongos or a replica set:
2828

29-
```
29+
```ini
3030
mongodb://host1:27017,host2:27017
3131
```
3232

3333
The [authentication guide]({{< relref "authenticating.md" >}}) contains information on how to provide credentials.
3434

3535
#### The Database Component
3636

37-
The database component is optional and is used to indicate which database to authenticate against. When the database component is not
38-
provided, the "admin" database is used.
37+
The database component is optional and is used to indicate which database to authenticate against. When the database component is not
38+
provided, the "admin" database is used.
3939

40-
```
40+
```ini
4141
mongodb://host:27017/mydb
4242
```
4343

4444
Above, the database by the name of "mydb" is where the credentials are stored for the application.
4545

46-
> Note that some drivers utilize the database component to indicate which database to work with by default. The Java driver, while it
47-
parses the database component, does not use the database component for anything other than authentication.
46+
> Note that some drivers utilize the database component to indicate which database to work with by default. The Java driver, while it
47+
parses the database component, does not use the database component for anything other than authentication.
4848

4949
#### Options
5050

51-
Many options can be provided via the connection string. The ones that cannot may be provided in a `MongoClientOptions` instance. To
52-
provide an option, append a `?` to the connection string and separate options by an `&`.
51+
Many options can be provided via the connection string. The ones that cannot may be provided in a `MongoClientOptions` instance. To
52+
provide an option, append a `?` to the connection string and separate options by an `&`.
5353

54-
```
54+
```ini
5555
mongodb://host:27017/?replicaSet=rs0&maxPoolSize=200
5656
```
5757

5858
The above connection string sets the "replicaSet" value to "rs0" and the "maxPoolSize" to "200".
5959

60-
For a comprehensive list of the available options, see the [MongoClientURI](http://api.mongodb.org/java/3.0/com/mongodb/MongoClientURI.html)
60+
For a comprehensive list of the available options, see the [MongoClientURI](http://api.mongodb.org/java/3.0/com/mongodb/MongoClientURI.html)
6161
documentation.
6262

6363

6464
### MongoClient
6565

66-
A `MongoClient` instance will be the root object for all interaction with MongoDB. It is all that is needed to handle connecting to
67-
servers, monitoring servers, and performing operations against those servers. Without any arguments, constructing a `MongoClient`
66+
A `MongoClient` instance will be the root object for all interaction with MongoDB. It is all that is needed to handle connecting to
67+
servers, monitoring servers, and performing operations against those servers. Without any arguments, constructing a `MongoClient`
6868
instance will connect to "localhost" port 27017.
6969

7070
```java
@@ -77,7 +77,7 @@ Alternatively, a connection string may be provided:
7777
MongoClient client = new MongoClient(new MongoClientURI("mongodb://host:27017,host2:27017/?replicaSet=rs0"));
7878
```
7979

80-
Finally, the `MongoClientOptions` class provides an in-code way to set the same options from a connection string. This is sometimes
80+
Finally, the `MongoClientOptions` class provides an in-code way to set the same options from a connection string. This is sometimes
8181
necessary, as the connection string does not allow an application to configure as many configuration options as `MongoClientOptions`.
8282
`MongoClientOptions` instances are immutable, so to create one your application uses a builder:
8383

@@ -91,7 +91,7 @@ in code but others via the connection string:
9191

9292
```java
9393

94-
MongoClientURI uri = new MongoClientURI("mongodb://host:27017,host2:27017/?replicaSet=rs0",
94+
MongoClientURI uri = new MongoClientURI("mongodb://host:27017,host2:27017/?replicaSet=rs0",
9595
MongoClientOptions.builder().cursorFinalizerEnabled(false))
9696
MongoClient client = new MongoClient(uri);
9797
```

0 commit comments

Comments
 (0)