> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JDBC loading topic

> Configuration reference for `JdbcTopicDescription` properties such as `sql`, `parameterOrder`, `channels`, and source restrictions, defined under the `dlc.jdbc.topics` namespace.

### Configuration properties

Properties for a JDBC Loading Topic are defined by name in the `dlc.jdbc.topics` namespace,
and are picked up as configurations for the DLC.

| Key                   | Required | Type           | Default                                                                | Description                                                                                                                                |
| --------------------- | :------: | -------------- | :--------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| sql                   |     Y    | `String`       |                                                                        | SQL statement. Can accept parameters.                                                                                                      |
| parameterOrder        |          | `List<String>` |                                                                        | List which contains the order of scope keys for providing parameters to the prepared statement. Values come from the scope of the request. |
| channels              |          | `Set<Channel>` | A channel is created using the topic's name as the name of the target. | [Channels](/configuration/channel).                                                                                                        |
| restrict-to-sources   |          | `Set<String>`  |                                                                        | Sources *to* which the topic is restricted. See [source to topic matching](/functional/source-to-topic-matching).                          |
| restrict-from-sources |          | `Set<String>`  |                                                                        | Sources *from* which the topic is restricted. See [source to topic matching](/functional/source-to-topic-matching).                        |

#### YAML example

This configuration does not specify a target for the data or the data format.

<Note>
  If the topic is not named the same as the store, the target must be explicitly specified in the [channel](/configuration/channel) of the topic.
</Note>

* The target is implicitly the Atoti table named "Trades".
* The format (column order in the result of the SQL query and how input fields are parsed) implicitly comes from the columns and types of the targeted Atoti table, in this case "Trades".

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
dlc:
  jdbc:
    topics:
      trades:
        sql: 'SELECT * FROM table1'
      topic6:
        sql: 'SELECT ProductId AS ProductId,
                  Name AS  ProductName,
                  Color AS  ProductColor,
                  Price AS  ProductPrice,
                  CobDate AS  CobDate
                  FROM  ProductStore
                  WHERE  CobDate = ?'
        parameter-order:
          - CobDate
```

### Java configuration

`JdbcTopicDescription` Spring Beans are picked up as configurations for the DLC.

| Parameter           | Required | Type           | Default                                                                | Description                                                                                                                                |
| ------------------- | :------: | -------------- | :--------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| name                |     Y    | `String`       |                                                                        | Name of the topic.                                                                                                                         |
| sql                 |     Y    | `String`       |                                                                        | SQL statement. Can accept parameters.                                                                                                      |
| parameterOrder      |          | `List<String>` |                                                                        | List which contains the order of scope keys for providing parameters to the prepared statement. Values come from the scope of the request. |
| channels            |          | `Set<Channel>` | A channel is created using the topic's name as the name of the target. | [Channels](/configuration/channel).                                                                                                        |
| restrictToSources   |          | `Set<String>`  |                                                                        | Sources *to* which the topic is restricted. See [source to topic matching](/functional/source-to-topic-matching).                          |
| restrictFromSources |          | `Set<String>`  |                                                                        | Sources *from* which the topic is restricted. See [source to topic matching](/functional/source-to-topic-matching).                        |

#### Java example

This configuration does not specify a target for the data or the data format.

<Note>
  If the topic is not named the same as the store, the target must be explicitly specified in the [channel](/configuration/channel) of the topic.
</Note>

* The target is implicitly the Atoti table named "Trades".
* The format (column order in the result of the SQL query and how input fields are parsed) implicitly comes from the columns and types of the targeted Atoti table, in this case "Trades".

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public JdbcTopicDescription tradesTopic() {
    return JdbcTopicDescription.builder("trades", "SELECT * FROM table1")
            .build();
}

@Bean
public JdbcTopicDescription tradesTopic() {
    return JdbcTopicDescription.builder("Trades", """
                    SELECT ProductId AS ProductId,
                    Name AS  ProductName,
                    Color AS  ProductColor,
                    Price AS  ProductPrice,
                    CobDate AS  CobDate
                    FROM  ProductStore
                    WHERE  CobDate = ?""")
            .parameterOrder(List.of("CobDate"))
            .build();
}
```
