# Connect with Apache NiFi

Apache NiFi is a data integration and automation platform designed to ingest, move, transform, and manage data across various systems in real time. You can connect to SingleStore from Apache NiFi using [the SingleStore JDBC driver](https://docs.singlestore.com/db/v9.1/developer-resources/connect-with-application-development-tools/connect-with-java-jdbc/the-singlestore-jdbc-driver.md).

Refer to [Apache NiFi](https://nifi.apache.org/components/) documentation for more information.

## Prerequisites

1. [Download and install](https://nifi.apache.org/nifi-docs/getting-started.html#downloading-and-installing-nifi) Apache NiFi.

2. Install Java 21+.

3. [Download](https://github.com/memsql/S2-JDBC-Connector/releases/latest) the SingleStore JDBC driver `.jar` file.

4. Start Apache NiFi. Run the following command from the NiFi installation directory.
   ```shell
   ./bin/nifi.sh start
   ```

5. Copy the username and password from the generated log. Use these credentials to log in to NiFi Flow. For example,
   ```shell
   tail -n 100 <NiFi_installation_directory>/logs/nifi-app.log | grep Generated

   ```
   ```output

   Generated Username [eea280ec-6000-4000-a000-9aaf521ef5cf]
   Generated Password [He5Gd9ZHVgkA0JQR9d9uNc2A5WAHROI4]
   ```

## Configure the Connection to SingleStore

To configure the connection to SingleStore in NiFi Flow, perform the following:

1. Open NiFi Flow, go to <https://localhost:8443/nifi>.

2. Log in to NiFi Flow using the generated username and password.

3. On the **Nifi Flow** canvas, open the options menu (right-click) and select **Controller Services**.

4. Select the **+** icon.

5. On the **Add Controller Service** dialog, from the list of controllers, select **DBCPConnectionPool > Add**.

6. On the **Controller Services** page. Select the three dots for the controller added in the previous step, and then select **Edit**.

7. In the **Edit Controller Service** dialog,

   1. On the **Settings** tab, enter **SingleStore** in the **Name** field.

   2. On the **Properties** tab, enter or select the following:

      1. **Database Connection URL**: Specify the connection string for the SingleStore deployment in the following format:

         `jdbc:singlestore://<endpoint>:<port>/<database>`

      2. **Database Driver Class Name**: Specify `com.singlestore.jdbc.Driver`.

      3. **Database Driver Location**: Specify the path to the SingleStore JDBC driver `.jar` file downloaded earlier.

      4. **Database User**: Specify the username of the SingleStore database user with which to connect.

      5. **Password**: Specify the password for the SingleStore database user.

      6. Specify other connection configuration properties as applicable.

      7. Under **Verification**, select **✔ > Verify** to verify the connection configuration.

   3. After the connection configuration is verified, a message similar to the following is displayed:
      ```
      Perform Validation
      Component Validation passed
      Configure Data Source
      Successfully configured data source
      Establish Connection
      Successfully established Database Connection
      ```

   4. Select **Apply**. The **SingleStore** controller service is now configured.

8. Enable the **SingleStore** controller service. Select the three dots for the controller, and then select **Enable** from the list.

9. Close the **Enable Controller Service** dialog once the **SingleStore** controller service is enabled.

The connection to the SingleStore deployment is now configured. Specify the **SingleStore** controller service in processor configuration to connect to your SingleStore database.

## Example

The following example connects to a SingleStore deployment, runs a SQL query, and then stores the output in a file.

1. On the NiFi Flow canvas, add the **ExecuteSQL** processor by dragging the processor to the canvas.

2. Configure the ExecuteSQL processor. Open the options menu for the processor (right-click) and then select **Configure**.

3. On the **Edit Processor** dialog, enter or select the following:

   1. On the **Settings** tab, enter a name for the processor. For example, **Query table**.

   2. On the **Properties** tab, select **Database Connection Pooling Service** and then select **SingleStore** (the configured controller service) from the list.

   3. In the **SQL Query** field, enter a SQL query to run.

   4. Specify other connection configuration properties as applicable.

   5. Select **Apply**.

4. On the NiFi Flow canvas, add the **ConvertRecord** processor.

5. Configure the ConvertRecord processor. Open the options menu for the processor (right-click) and then select **Configure**.

6. On the **Edit Processor** dialog, enter or select the following:

   * **Record Reader**: Select the three dots and then select **Create new service > AvroReader**. This example uses the `AvroReader` service.
   * **Record Writer**: Select the three dots and then select **Create new service > JSONRecordSetWriter**. This example uses the `JSONRecordSetWriter` service.

7. On the NiFi Flow canvas, add the **PutFile** processor.

8. Configure the PutFile processor. Open the options menu for the processor (right-click) and then select **Configure**.

9. In the **Edit Processor** dialog, enter or select the following:

   1. On the **Properties** tab, enter the path to the directory where the output file is stored in the **Directory** field.

   2. On the **Relationships** tab, select **terminate** for success and failure.

   3. Select **Apply**.

10. Configure the relationships between the ExecuteSQL, ConvertRecord, and PutFile processors.

11. (If required) Enable all the controller services. Open the options menu for the canvas (right-click), and then select **Enable All Controller Services**.

12. Open the options menu for the canvas and select **Start**.

13. The output is written to a file in the specified directory. For example,
    > **📝 Note**: The output is formatted for readability.
    ```shell
    cat 0b570ff9-9000-4000-9000-9eff3d4dde09

    ```
    ```output

    [ {
        "id": 2,
        "created": "2025-06-05 11:58:23.978207",
        "payload": "{\"eventId\":202,\"tags\":[\"music\",\"concert\"]}"
      },
      {
        "id": 3,
        "created": "2025-06-05 11:58:23.978207",
        "payload": "{\"eventId\":101,\"tags\":[\"sports\",\"indoor\"]}"
      },
      {
        "id": 1,
        "created": "2025-06-05 11:58:23.978207",
        "payload": "{\"eventId\":101,\"tags\":[\"sports\",\"outdoor\",\"fun\"]}"
      }]
    ```

***

Modified at: September 26, 2025

Source: [/db/v9.1/load-data/integrate-with-singlestore/connect-with-apache-nifi/](https://docs.singlestore.com/db/v9.1/load-data/integrate-with-singlestore/connect-with-apache-nifi/)

(An index of the documentation is available at /llms.txt)
