Apache NiFi is a reliable, web-based system for automating data flows between systems. This guide walks you through connecting Apache NiFi to Hologres and writing a local JSON file to a Hologres table using three processors: GetFile, ConvertJSONToSQL, and PutSQL.
How it works
The pipeline uses three processors in sequence:
-
GetFile — reads a local file in JSON format
-
ConvertJSONToSQL — converts each JSON element into a SQL INSERT statement
-
PutSQL — executes the INSERT statement and writes the data to Hologres
Prerequisites
Before you begin, make sure you have:
-
A running Hologres instance. See Purchase a Hologres instance.
-
Apache NiFi installed. See How to install and start NiFi.
Step 1: Gather connection details
Collect the following information before starting the configuration. You'll need it when setting up the DBCPConnectionPool controller service.
| Detail | Where to find it |
|---|---|
| Hologres endpoint | Instance details page in the Hologres Management Console. Use a public endpoint or VPC endpoint depending on your network. |
| Database name | The name of the database to write data to (this guide uses demo) |
| AccessKey ID | AccessKey Management in the Alibaba Cloud console |
| AccessKey secret | AccessKey Management in the Alibaba Cloud console |
Step 2: Download the PostgreSQL JDBC driver
Apache NiFi uses a JDBC driver to connect to Hologres, which is PostgreSQL-compatible.
-
Download the PostgreSQL JDBC driver (version 42.2.25 or later) from the PostgreSQL official website.
-
Place the JAR file in a directory accessible by NiFi, for example:
/opt/nifi/nifi-current/jdbc_driver/. -
Note the absolute path to the JAR file — you'll enter it when configuring DBCPConnectionPool.
Step 3: Create a database and table
-
Log in to your Hologres instance and create a database named
demo. See Create a database. -
Run the following SQL statement to create the target table:
DROP TABLE IF EXISTS user_info; CREATE TABLE IF NOT EXISTS user_info ( id int, first_name text, last_name text, email text );
Step 4: Configure the GetFile processor
-
Add a GetFile processor. See Adding a processor in the NiFi documentation.
-
On the PROPERTIES tab, set Input Directory to the path where your JSON file is stored. For example, if your JSON file is at
/opt/nifi/nifi-current/file_source/user_info.json, the file content looks like this:{ "id": 1, "first_name": "Sig", "last_name": "Olivo", "email": "solivo0@blinklist.com" }
-
Click APPLY.
Step 5: Configure the ConvertJSONToSQL processor
-
Add a ConvertJSONToSQL processor.
-
In JDBC Connection Pool, add a controller service. Set Compatible Controller Services to DBCPConnectionPool and Controller Service Name to
hologres.
-
Click the arrow button on the right side of the JDBC Connection Pool row to open the controller service configuration.
-
Find the DBCPConnectionPool service you just created and click the settings button.

-
On the PROPERTIES tab, configure the following parameters:
Parameter Value Notes Database Connection URL jdbc:postgresql://<endpoint>/<database name>— for example,jdbc:postgresql://hgpostcn-cn-xxxxxxxxxxx-cn-shanghai.hologres.aliyuncs.com:80/demoUse either a public network or VPC endpoint. To get the endpoint, go to the instance details page in the Hologres Management Console. Database Driver Class Name org.postgresql.DriverNot applicable Database Driver Location(s) Absolute path to the JDBC driver JAR — for example, /opt/nifi/nifi-current/jdbc_driver/postgresql-42.3.4.jarMust be accessible by the NiFi process. Use the path from Step 2. Database User Your AccessKey ID Obtained from AccessKey Management in Step 1. Password Your AccessKey secret Obtained from AccessKey Management in Step 1. 
-
Click OK.
-
Click ENABLE to start the controller service.
-
Return to the ConvertJSONToSQL processor and configure the following parameters. For details on each parameter, see the NiFi documentation.
Parameter Value Statement Type INSERTTable Name user_infoSchema Name public -
Click APPLY.
Step 6: Configure the PutSQL processor
-
Add a PutSQL processor.
-
Set JDBC Connection Pool to the DBCPConnectionPool controller service configured in the previous step (named
hologres). -
Set Support Fragmented Transactions to
false. -
Click APPLY.
Step 7: Start writing data
Set all processors to the running state. NiFi reads the JSON file and writes the data to Hologres.
Step 8: Verify the data
Run the following query in Hologres to confirm that the data was written successfully:
SELECT * FROM user_info;