# Database Task

Use the **Database Task** to execute **database commands** as part of a Microflow or Process Flow.\
This task enables direct interaction with databases, allowing data to be retrieved, inserted, updated, or deleted during integration execution.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FbArE6qOipj0LBe4UmRtB%2Fimage.png?alt=media&#x26;token=1fa82efd-df55-4d70-8825-8b264e919f73" alt=""><figcaption></figcaption></figure>

***

### Purpose

The **Database Task** is used when a Microflow needs to:

* Retrieve data from a database to drive integration logic
* Insert new records into a database
* Update existing records
* Delete records

Most integration flows rely on database interactions in order to:

* Fetch reference or transactional data
* Persist results of external integrations
* Synchronize data across systems

ONEWEB provides this functionality through visually configurable **Database Node Tasks**, without requiring custom JDBC code.

***

### Database Task Configuration

The **Database Task Configuration Panel** consists of **three tabs**.

***

#### General Tab

The **General** tab contains basic metadata for the node:

* Task Name
* Task ID (system‑generated)
* Description

These properties help identify and document the Database Task within the flow.

***

#### Business Object Tab

The **Business Object** tab is used to configure:

* Input Business Objects
* Output Business Objects

Business Objects represent the data exchanged between the Microflow and the database operation.

***

#### Database Parameter Tab

The **Database Parameter** tab defines how and what database operation is executed.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FpsWsTURYQQIcrRaeITzV%2F1?alt=media" alt=""><figcaption></figcaption></figure>

| Property        | Mandatory | Description                                                                                                          |
| --------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
| Configured By   | Yes       | Choose whether the SQL is configured manually (**Process Designer**) or derived from **Data Designer / SQL Builder** |
| Connection Type | Yes       | Choose **JNDI** or **JDBC**                                                                                          |
| Command Type    | Yes       | SELECT, INSERT, UPDATE, or DELETE                                                                                    |
| Command         | Yes       | SQL statement to be executed                                                                                         |

***

### Database Connection Types

#### Java Naming and Directory Interface (JNDI)

**JNDI** allows database connections to be referenced using a managed name provided by the application server.

When **Connection Type** is set to **JNDI**, the following properties are required:

| Property        | Mandatory | Description                                 |
| --------------- | --------- | ------------------------------------------- |
| Use Environment | No        | Select JNDI name from environment variables |
| JNDI Name       | Yes       | JNDI name for the database connection       |

**Recommended for** managed and enterprise environments.

***

#### Java Database Connectivity (JDBC)

**JDBC** provides direct database connectivity using connection details.

When **Connection Type** is set to **JDBC**, users must configure:

| Property             | Mandatory | Description                                |
| -------------------- | --------- | ------------------------------------------ |
| JDBC Database Driver | Yes       | Fully qualified driver class name          |
| Use Environment      | No        | Select JDBC URL from environment variables |
| JDBC URL             | Yes       | Database connection URL                    |
| JDBC Username        | Yes       | Database username                          |
| JDBC Password        | Yes       | Database password                          |

**Recommended for** custom or external database integrations.

***

### Parameter Mapping

The **Open Mapping Parameter** button allows users to map:

* Microflow input parameters → SQL parameters
* SQL output values → Microflow output parameters

When clicked, the system redirects to the **Mapping Parameter screen**, where:

* **Mapping Parameter Input**
* **Mapping Parameter Output**

lines can be used to configure data flow for the Database Task.

This ensures seamless data exchange between database operations and other integration nodes.

***

### Best Practices

* Prefer **JNDI** over JDBC in managed environments
* Externalize connection details using environment variables
* Keep SQL queries clean and focused
* Avoid embedding complex business logic in SQL
* Validate output mappings carefully

***

### Summary

The **Database Task** is a core integration node in ONEWEB that enables Microflows to interact directly with databases.

Using Database Task, applications can:

* Execute SELECT, INSERT, UPDATE, and DELETE operations
* Integrate with databases using JNDI or JDBC
* Map SQL results to Business Objects
* Use database data to drive integration workflows

Database Task allows ONEWEB applications to **reliably and visually integrate with relational databases**, making it a foundational component for enterprise‑grade integration flows.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/oneweb-platform-th/designer-reference/microflow-designer/activity-nodes/database-task.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
