MongoDB Connection Options

Connection String Options

  1. Auth Database
  2. Auto Cache
  3. Cache Connection
  4. Cache Driver
  5. Cache Location
  6. Cache Metadata
  7. Database
  8. Firewall Password
  9. Firewall Port
  10. Firewall Server
  11. Firewall Type
  12. Firewall User
  13. Flatten Arrays
  14. Flatten Objects
  15. Location
  16. Logfile
  17. Max Log File Size
  18. Max Results
  19. Offline
  20. Other
  21. Password
  22. Port
  23. Proxy Auth Scheme
  24. Proxy Auto Detect
  25. Proxy Password
  26. Proxy Port
  27. Proxy Server
  28. Proxy SSL Type
  29. Proxy User
  30. Pseudo Columns
  31. Query Cache
  32. Readonly
  33. Read Preference
  34. Row Scan Depth
  35. RTK
  36. Server
  37. Slave OK
  38. SSL Cert
  39. Tables
  40. Timeout
  41. User
  42. Use SSL
  43. Verbosity

Auth Database

Data Type

string

Default Value

""

Remarks

The name of the MongoDB database for authentication. Only needed if the authentication database is different from the database to retrieve data from.



Auto Cache

Data Type

bool

Default Value

false

Remarks

When AutoCache is set, the driver automatically caches the results of SELECT queries to a cache specified by the CacheLocation option. The CacheLocation is a simple, file-based cache. See the CacheConnection and CacheDriver properties to cache to other databases.

Non-queries (such as UPDATE/INSERT/DELETE statements) on the original tables will not modify the data in the cache at all, regardless of the value set for AutoCache.

Note that while Offline is TRUE, the driver ignores AutoCache.



Cache Connection

Data Type

string

Default Value

""

Remarks

The cache database is determined based on CacheDriver and the CacheConnection properties. The CacheConnection defines the connection properties necessary to connect to the cache database.

Cache Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver;Cache Connection='jdbc:sqlserver://localhost:7437;user=sa;password=123456;databaseName=Cache'



Cache Driver

Data Type

string

Default Value

""

Remarks

You can cache to any database that you have a JDBC driver for. The driver has been tested with SQL Server, Derby, MySQL, Oracle, and SQLite.

The cache database is determined based on CacheDriver and the CacheConnection properties. The CacheDriver is the name of the JDBC driver class that you would like to use to cache data. The example below caches to SQL Server:

Cache Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver;Cache Connection='jdbc:sqlserver://localhost:7437;user=sa;password=123456;databaseName=Cache'



Cache Location

Data Type

string

Default Value

""

Remarks

If AutoCache is set but the cache location is not specified, CacheLocation defaults to the cache folder on the directory specified by the Location setting.

The CacheLocation is a simple, file-based cache. See the CacheConnection and CacheDriver properties to cache to other databases. The CacheLocation property relies on the Derby JDBC driver. To use this property you must include the derby.jar in your classpath. This file is located in the lib subfolder in the installation directory.



Cache Metadata

Data Type

bool

Default Value

false

Remarks

The cache.db file will be created in the location specified by the CacheConnection or if that is not set, the CacheLocation.



Database

Data Type

string

Default Value

""

Remarks

The name of the MongoDB database.



Firewall Password

Data Type

string

Default Value

""

Remarks

If FirewallServer is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall.



Firewall Port

Data Type

string

Default Value

""

Remarks

Note that the driver sets the FirewallPort to the default port associated with the specified FirewallType. See the description of the FirewallType option for details.



Firewall Server

Data Type

string

Default Value

""

Remarks

If this property is set to a domain name, a DNS request is initiated and the name is translated to the corresponding IP address.



Firewall Type

Data Type

string

Default Value

"NONE"

Remarks

The applicable values are:

Firewall Type Default FirewallPort
TUNNEL 80
SOCKS4 1080
SOCKS5 1080



Firewall User

Data Type

string

Default Value

""

Remarks

If the FirewallServer is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate against the firewall.



Flatten Arrays

Data Type

string

Default Value

""

Remarks

By default, nested arrays are returned as strings of JSON. The FlattenArrays property can be used to flatten the elements of nested arrays into columns of their own. This is only recommended for arrays that are expected to be short.

Set FlattenArrays to the number of elements you want to return from nested arrays. The specified elements are returned as columns. The zero-based index is concatenated to the column name. Other elements are ignored.

For example, you can return an arbitrary number of elements from an array of strings:

["FLOW-MATIC","LISP","COBOL"]
When FlattenArrays is set to 1, the preceding array is flattened into the following table:

Column NameColumn Value
languages_0FLOW-MATIC



Flatten Objects

Data Type

bool

Default Value

true

Remarks

By default, objects nested in arrays are returned as strings of JSON. When FlattenObjects is set to true, object properties are flattened into columns of their own. The property name is concatenated onto the object name with an underscore to generate the column name.

For example, you can flatten the nested objects below at connection time:

[
     { "grade": "A", "score": 2 },
     { "grade": "A", "score": 6 },
     { "grade": "A", "score": 10 },
     { "grade": "A", "score": 9 },
     { "grade": "B", "score": 14 }
]
When FlattenObjects is set to true and FlattenArrays is set to 1, the preceding array is flattened into the following table:

Column NameColumn Value
grades_0_gradeA
grades_0_score2



Location

Data Type

string

Default Value

""

Remarks

The path to a directory which contains the schema files for the driver (.rsd files for tables and views, .rsb files for stored procedures). The Location property is only needed if you would like to customize definitions (e.g., change a column name, ignore a column, etc.) or extend the data model with new tables, views, or stored procedures.

The schema files used in your application must be deployed with other assemblies. You must also ensure that Location points to the folder that contains the schema files. The folder location can be a relative path from the location of the executable.



Logfile

Data Type

string

Default Value

""

Remarks

For more control over what is written to the log file, take a look at Verbosity.



Max Log File Size

Data Type

string

Default Value

""

Remarks

A string specifying the maximum size in bytes for a log file (ex: 10MB). When the limit is hit, a new log is created in the same folder with the date and time appended to the end. There is no limit by default. Values lower than 100kB will use 100kB as the value instead.



Max Results

Data Type

string

Default Value

"-1"

Remarks

The number of rows to return per query. -1 means unlimited. This property will have no effect if LIMIT is specified.



Offline

Data Type

bool

Default Value

false

Remarks

When Offline is set to TRUE, all queries execute against the cache as opposed to the live data source. In this mode, certain queries like INSERT, UPDATE, DELETE, and CACHE are not allowed.



Other

Data Type

string

Default Value

""

Remarks

The Other property is a semicolon-separated list of name-value pairs used in connection parameters specific to a data source. Some of the other properties are:

CachePartial=TrueCaches only a subset of columns, which you can specify in your query.
QueryPassthrough=TruePasses the specified query to the cache database instead of using the SQL parser of the driver.
RecordToFile=filenameRecords the underlying socket data transfer to the specified file.



Password

Data Type

string

Default Value

""

Remarks

The password used to authenticate with MongoDB.



Port

Data Type

string

Default Value

"27017"

Remarks

The port for the MongoDB database.



Proxy Auth Scheme

Data Type

string

Default Value

""

Remarks

This value may be BASIC, DIGEST, NONE, NTLM, NEGOTIATE or PROPRIETARY.



Proxy Auto Detect

Data Type

bool

Default Value

true

Remarks

This indicates whether to use the default system proxy settings or not. Set ProxyAutoDetect to FALSE to use custom proxy settings. This takes precedence over other proxy settings.



Proxy Password

Data Type

string

Default Value

""

Remarks

If the ProxyServer is specified, the ProxyUser and ProxyPassword properties are used to connect and authenticate against the firewall.



Proxy Port

Data Type

string

Default Value

""

Remarks

See the description of the ProxyServer field for details.



Proxy Server

Data Type

string

Default Value

""

Remarks

If this property is set to a domain name, a DNS request is initiated and the name is translated to the corresponding address.



Proxy SSL Type

Data Type

string

Default Value

""

Remarks

This value may be AUTO, ALWAYS, NEVER, or TUNNEL.



Proxy User

Data Type

string

Default Value

""

Remarks

If a ProxyServer is specified, the ProxyUser and ProxyPassword options are used to connect and authenticate against the firewall.



Pseudo Columns

Data Type

string

Default Value

""

Remarks

This setting is particularly helpful in Entity Framework, which does not allow you to set a value for a pseudo column unless it is a table column. The value of this connection setting is of the format "Table1=Column1, Table1=Column2, Table2=Column3". You can use the "*" character to include all tables and all columns; i.e., "*=*".



Query Cache

Data Type

string

Default Value

""

Remarks

The QueryCache allows you to cache the results of a query in-memory and use them until the cache expires. Setting the QueryCache can improve performance if the same or similar (see below) queries are executed often. The in-memory query cache is shared across connections, so it can help with performance even if more than one connection is being used.

The cache manager for QueryCache will not only use the results in the cache for exactly the same query, but also for queries that represent a subset of data in the cached query. For example, in the following queries, the cache created while executing Query A will be used to obtain the results for both Query B and Query C.

SELECT * from Account; // Query A
SELECT * from Account WHERE Name LIKE '%John'; // Query B
SELECT Id, Name from from Account LIMIT 10; // Query C

Setting the QueryCache to zero disables in-memory caching.



Readonly

Data Type

bool

Default Value

false

Remarks

If this property is set to true, the driver will allow only SELECT queries. INSERT, UPDATE, DELETE, and stored procedure queries will cause an error to be thrown.



Read Preference

Data Type

string

Default Value

""

Remarks

Set this property to specify the read preference mode. Accepted values are primary, primaryPreferred, secondary, secondaryPreferred, and nearest.



Row Scan Depth

Data Type

string

Default Value

"100"

Remarks

Since MongoDB is schemaless, the columns in a table must be determined by scanning table rows. This value determines the maximum number of rows that will be scanned. The default value is 100.

Setting a high value may decrease performance. Setting a low value may prevent the data type from being determined properly, especially when there is null data.



RTK

Data Type

string

Default Value

""

Remarks

The RTK property may be used to license a build. Please see the included licensing file to see how to set this property. The runtime key is only available if you purchased an OEM license.



Server

Data Type

string

Default Value

""

Remarks

The host name or IP address of the server hosting the MongoDB database.



Slave OK

Data Type

bool

Default Value

false

Remarks

This property sets whether the driver is allowed to read from secondary (slave) servers.



SSL Cert

Data Type

string

Default Value

""

Remarks

If using an SSL connection, this property can be used to specify the SSL certificate to be accepted from the server. Any other certificate that is not trusted by the machine will be rejected. This can take the form of a full PEM certificate, the path to a file containing the certificate, the public key, the MD5 thumbprint, or the SHA1 thumbprint. If not specified, any valid certificate will be accepted. Use '*' to signify to accept all certificates. Do not specify the SSLCert to only accept certificates that the machine already trusts.



Tables

Data Type

string

Default Value

""

Remarks

Listing the tables from some databases can be expensive. Providing a list of tables in the connection string improves the performance of the driver.



Timeout

Data Type

string

Default Value

"60"

Remarks

If the Timeout property is set to 0, operations do not time out: They run until they complete successfully or encounter an error condition.

If Timeout expires and the operation is not yet complete, the driver throws an exception.



User

Data Type

string

Default Value

""

Remarks

The username used to authenticate with MongoDB.



Use SSL

Data Type

bool

Default Value

false

Remarks

This field sets whether SSL is enabled.



Verbosity

Data Type

string

Default Value

"1"

Remarks

The verbosity level determines the amount of detail that the driver reports to the Logfile. Verbosity levels from 1 to 5 are supported. These are described below:

1Setting Verbosity to 1 will log the query, the number of rows returned by it, the start of execution and the time taken, and any errors.
2Setting Verbosity to 2 will log everything included in Verbosity 1, cache queries, and HTTP headers.
3Setting Verbosity to 3 will additionally log the body of the HTTP requests.
4Setting Verbosity to 4 will additionally log transport-level communication with the data source. This includes SSL negotiation.
5Setting Verbosity to 5 will additionally log communication with the data source and additional details that may be helpful in troubleshooting problems. This includes interface commands.

The Verbosity should not be set to greater than 1 for normal operation. Substantial amounts of data can be logged at higher verbosities, which can delay execution times.