# tMongoDBConnection

Creates a connection to a MongoDB database and reuse that connection in other components.

tMongoDBConnection opens a connection to a database in order that a transaction may be made.

This component is not shipped with your Talend Studio by default. You need to install it using the Feature Manager. For more information, see [Installing features using the Feature Manager](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/install-features-to-talend-studio).

## tMongoDBConnection Standard properties

These properties are used to configure tMongoDBConnection running in the Standard Job framework.

The Standard tMongoDBConnection component belongs to the Big Data and the Databases NoSQL families.

The component in this framework is available in all Talend products with Big Data and in Talend Data Fabric.

## Basic settings

| Properties | Description |
| --- | --- |
| DB Version | List of the database versions. |
| Use connection string | Select this option to establish a connection using a MongoDB<br>Atlas URI. Enter the URI in the field to the right. See [Connection String URI Format](https://docs.mongodb.com/manual/reference/connection-string/) for related information.<br><br>This option is available when you select MongoDB 4.4.X and<br>later from the DB Version drop-down<br>list.<br><br>Information noteNote: This option is available only when you have installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator. |
| Use replica set address | Select this check box to show the Replica<br>address table.<br><br>In the Replica address table, you can<br>define multiple MongoDB database servers for failover. |
| Server and Port | IP address and listening port of the database server.<br><br>Available when the Use replica set<br>address check box is not selected. |
| Database | Name of the database. |
| Use SSL connection (Configure the SSL authentication<br>in tSetKeystore or in Studio preferences) | Select this checkbox to enable the SSL or TLS encrypted connection.<br><br>Then you must specify the encryption information using one of<br>these methods:<br><br><ul> <li>If you want to centralize the connection information, set up the SSL                           connection in <span><span>Windows</span><abbr> &gt; </abbr><span>Preferences</span><abbr> &gt; </abbr><span>Talend</span><abbr> &gt; </abbr><span>SSL</span></span> and check the <span>Enable SSL</span> field in                           the MongoDB connection configuration in                           <span>Metadata</span>.</li> <li>If you want to keep this information within the scope of this Job, use                           the <span>tSetKeystore</span> component in the                           same Job.</li> </ul><br><br>Note that the SSL connection is available only for the version 2.4 + of<br>MongoDB. |
| Required authentication | Select this check box to enable the database authentication.<br><br>Among the mechanisms listed on the Authentication mechanism<br>drop-down list, the NEGOTIATE one is recommended if<br>you are not using Kerberos, because it automatically select the authentication mechanism<br>the most adapted to the MongoDB version you are using.<br><br>Because the SCRAM-SHA-256 authentication mechanism is only supported by<br>MongoDB 4.x and later versions, SCRAM-SHA-256 SASL option is available<br>only when MongoDB 4.4.X and later is selected from the DB<br>Version drop-down list.<br><br>Information noteNote: The X509 option is available only when you have<br>installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.<br><br>For details about the other mechanisms in this list, see [MongoDB Authentication](https://docs.mongodb.org/manual/reference/parameters/#param.authenticationMechanisms) from the MongoDB<br>documentation. |
| Set Authentication database | If the username to be used to connect to MongoDB has been created in a specific<br>Authentication database of MongoDB, select this check box to enter the name of this<br>Authentication database in the Authentication database<br>field that is displayed.<br><br>For further information about the MongoDB Authentication database, see [User Authentication database](https://docs.mongodb.org/manual/core/security-users/#user-authentication-database). |
| Username and Password | DB user authentication data.<br><br>To enter the password, click the [...] button<br>next to the password field, enter the password in double quotes in the pop-up dialog box,<br>and click OK to save the settings.<br><br>Available when the Required<br>authentication check box is selected.<br><br>If the security system you have selected from the Authentication mechanism dropdown list is Kerberos, you need to<br>enter the User principal, the Realm and the KDC<br>server fields instead of the Username and the Password<br>fields. |

## Advanced settings

| Properties | Description |
| --- | --- |
| tStatCatcher Statistics | Select this check box to collect the log data at a component level. |
| No query timeout | Select this check box to prevent MongoDB servers from stopping idle<br>cursors at the end of 10-minute inactivity of these cursors. In this<br>situation, an idle cursor will stay open until either the results of<br>this cursor are exhausted or you manually close it using the<br>cursor.close() method.<br><br>A cursor for MongoDB is a pointer to the result set of a query. By<br>default, that is to say, with this check box being clear, a MongoDB<br>server automatically stops idle cursors after a given inactivity period<br>to avoid excess memory use. For further information about MongoDB<br>cursors, see https://docs.mongodb.org/manual/core/cursors/.<br><br>This parameter is only available when you select MongoDB<br>3.5.x from the DB version drop-down list<br>in the Basic settings tab. |
| Apply optional attributes | Select this option to set and apply optional attributes for the connection to be established.<br><br>In the Optional attributes table, click the plus<br>button on the bottom to add a row, select the desired attribute from the<br>drop-down list in the Name column, and set a<br>value for the attribute in the Value column. |

## Global Variables

| Variables | Description |
| --- | --- |
| Global Variables | ERROR\_MESSAGE: the error message generated by the<br>component when an error occurs. This is an After variable and it returns a string. This<br>variable functions only if the Die on error checkbox is<br>cleared, if the component has this checkbox.<br><br>A Flow variable functions during the execution of a component<br>while an After variable functions after the execution of the component.<br><br>To fill up a field or expression with a variable, press Ctrl+Space to access the variable list and choose the variable to use from<br>it.<br><br>For more information about variables, see [Using contexts and variables](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/contexts-and-variables). |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is generally used with other MongoDB components,<br>particularly tMongoClose. |

**Related concepts**

* [Creating a collection and writing data to it](https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbinput-tmongodboutput-tlogrow-creating-collection-and-writing-data-to-it-standard-component-bigdata-this)
* [Inserting records to a MongoDB collection using a dynamic schema](https://help.qlik.com/talend/en-US/components/8.0/mongodb/inserting-records-to-a-mongodb-collection-using-dynamic-schema)
* [Managing files using MongoDB GridFS](https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbgridfslist-tmongodbgridfsproperties-tlogrow-managing-files-using-mongodb-gridfs-standard-component-bigdata-in-this)
* [Retrieving data from a collection by advanced queries](https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbinput-tmongodbconnection-tmongodbclose-tlogrow-retrieving-data-from-collection-by-advanced-queries-standard-component-bigdata-in-this)
* [Upserting records in a collection](https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbinput-tmongodboutput-tlogrow-upserting-records-in-collection-standard-component-bigdata-this)
* [Using MongoDB functions to create a collection and write data to it](https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbinput-tmongodbrow-tlogrow-using-mongodb-functions-to-create-collection-and-write-data-to-it-standard-component-bigdata-this)