All Products
Search
Document Center

AnalyticDB:FineReport

Last Updated:Mar 28, 2026

Connect FineReport to an AnalyticDB for MySQL cluster to query data and build reports directly on your cluster.

Prerequisites

Before you begin, ensure that you have:

Connect to AnalyticDB for MySQL

Connection parameters

ParameterValue
DatabaseMySQL
Drivercom.mysql.jdbc.Driver
URLjdbc:mysql://<hostname>:<port>
UsernamePrivileged account or standard account
PasswordAccount password

Where:

  • <hostname>: the public or Virtual Private Cloud (VPC) endpoint of your cluster.

  • <port>: the port of the cluster endpoint. Default: 3306.

Steps

  1. Start FineReport. In the top menu bar, choose Server > Define Data Connection.

  2. In the Define Data Connection dialog, set the parameters shown in the table above.

    Configure connection parameters

  3. Click Test Connection. After the test passes, click OK.

You are now connected to your AnalyticDB for MySQL cluster. Next, create datasets to query data for your reports.

Create a dataset

A dataset contains data retrieved from your cluster using SQL statements. FineReport displays datasets as two-dimensional tables in the dataset management panel.

  1. Click the Template Dataset tab, then click the + icon in the upper-left corner.

    221040803

  2. Select DB Query from the drop-down list.

    2

  3. In the DB Query dialog, set Name to ds1. Select your AnalyticDB for MySQL cluster from the drop-down in the upper-left corner. Click a table in the left-side list, then enter your SQL in the right-side editor. For example, to retrieve all data from demo_sales:

    select * from demo_sales

    2021040802

  4. To create an aggregate dataset, add another dataset named ds2. For example, to get total sales by store:

    SELECT <Store name>, SUM(Revenue) AS <Total sales volume> FROM demo_sales GROUP BY <Store name>
  5. Click OK. The retrieved data appears in the dataset management panel.

Build a report

This section walks through a complete example: a report with tables and column charts showing maximum and total sales volumes by product type, payment type, and contract type.

2021040804

Set up the demo data

  1. Download the demo_contract table.

  2. Create the demo_contract table in your AnalyticDB for MySQL cluster. Use a column with evenly distributed values as the distribution key and a time column as the partition key. See Table schema design for guidance. In this example, contract_id is used as the distribution key because its values are randomly distributed:

    Create Table `demo_contract` (
     `contract_id` varchar,
     `customer_id` varchar,
     `contract_type` varchar,
     `amount` bigint,
     `payment_type` varchar,
     `register_time` date,
     `purchase_amount` int,
     `create_time` timestamp,
     `product_type` smallint,
     `paid` tinyint,
     primary key (`contract_id`)
    ) DISTRIBUTED BY HASH(`contract_id`) INDEX_ALL='Y' STORAGE_POLICY='COLD'
  3. Import data from the XLSX file to AnalyticDB for MySQL using Kettle. See Use Kettle to import data to Data Warehouse Edition. After the import, run the following to verify the data:

    SELECT count(*) FROM demo_contract

    The query returns 668 entries.

Import datasets into FineReport

Create two datasets in FineReport using the imported data.

  1. Create dataset d1 to get the maximum sales volume by product type, contract type, and payment type:

    select product_type, payment_type, contract_type, max(purchase_amount) as max_amount from demo_contract group by product_type, payment_type, contract_type having max_amount>0
  2. Create dataset d2 to get total sales by product type and contract type: Categorize data by product type and contract type, and calculate the total sales volume across all payment types. 20210408052021040806

Design the table

  1. Title: Merge cells A1 to D2. Enter Contract Sales Overview in the merged cell, set the font size to 15, and make it bold and centered.

  2. Angled header: Merge cells A3 and B3. Right-click the merged cell and choose Cell Element > Insert Slash. In the Slope Line dialog, enter:

    Payment Type | Contract Type | Product Type

    Add spaces to adjust text positions. 20210408072021040808

  3. Formulas: Drag the data columns with uneven value distribution to the corresponding cells. Then add the following formulas:

    • Click cell C5. Click the Insert Formula icon in the shortcut bar. In the Formula Definition dialog, enter SUM(C4) to sum total sales by product.

    • Click cell D5 and add SUM(D4) to sum total sales across all products.

    2021040809

  4. Expansion directions: Control how data expands across cells.

    • Click cell C3. In the panel, click Cell Attributes > Expand tab. In the Basic section, set Expand Direction to H so product type data expands horizontally.

    • Set Expand Direction to No Expansion for cells C4, C5, and D5, because these cells hold unique values tied to specific combinations.

    2021040811

  5. Dataset association: When multiple datasets appear in the same report, link them using shared fields. Datasets d1 and d2 both contain product_type and contract_type, so use these fields to associate the two datasets. Double-click cell D4. In the Data Column dialog, click the Filter tab and add a common condition to link product_type and contract_type across d1 and d2. 20210408122021040813

Add a column chart

  1. Merge cells A7 to D15. In the top menu bar, choose Insert > Cell Element > Insert Chart. Select Column Chart from the Chart Type list, choose Column Chart in the right-side list, and click OK.

    2021040814

  2. Click the chart. In the panel, click Cell Element. On the Data tab, set the following:

    • Data Source: Cell Data

    • Category: =B4

    • Series: =C3

    • Value: =C4

    Note

    Prefix each cell reference with =. Without the =, FineReport treats the value as a string instead of a cell reference.

    2021040815

Preview the report

Save the report first, then click Preview and select Pagination Preview from the drop-down. The report opens in your browser.

What's next