# mulesoft Database Connector - Full Documentation --- product: Database Connector version: 1.14 --- # Call Oracle Stored Procedure That Uses User-Defined Types (UDT) Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Oracle enables you to create your custom data types, known as _user-defined types (UDTs)_. The following example shows how to configure Anypoint Connector for Database (Database Connector) **Stored procedure** operation in a Mule application to call a stored procedure that uses UDTs from an Oracle database. The stored procedure performs two actions: - Inserts the first name, last name, age, and phone number of people whose age is less than 100 into a table - Returns a list of phone numbers of all the people added to the table To accomplish this example, you must: - Run a script to create UDTs, the table, and the stored procedure - Configure an Oracle database connection - Create the Mule application - Use `prepareStruct` and `prepareArray` DataWeave functions to map application data to custom types - Run and test the application with curl commands ![The Oracle UDTs flow in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracle-udt-flow.png) Figure 1. Oracle Stored procedure with UDTs Flow ## Using prepareStruct and prepareArray Functions Previous Mule versions provided the `createStruct` and `createArray` functions, which are now deprecated. These functions created JDBC values right away, when they must have been created with the same connection used in the Database Connector operation. The new `prepareStruct` and `prepareArray` functions enable Database Connector to defer these JDBC values creation until the right SQL connection is available. The `createArray` and `createStruct` functions used to work only with an Oracle Connection provider. Now, the `preprareStruct` and `prepareArray` functions are compatible with all connection providers, such as the Generic Connection provider or the DataSource Reference connection provider for example, where you can successfully configure load balancing and fault tolerance URI for the connection.
Deprecated FunctionActive Function

Db::createArray(configName, typeName, values): java.sql.Array

Db::prepareArray(typeName, values): java.util.List

Db::createStruct(configName, typeName, properties): java.sql.Struct

Db::prepareStruct(typeName, properties): java.util.List

### Parameters The `Db::prepareArray(typeName, values): java.util.List` function prepares an array to send to the database as a `java.sql.Array`.
ParameterTypeDescription

typeName

String

Name of the Array type to create.

values

List<Object>

Values to pass to the database.

java.util.List

List<Object>

The return value is an immutable list that holds all the information for creating an array later.

The `Db::prepareStruct(typeName, properties): java.util.List` function prepares a `struct` to send to the database as a `java.sql.Struct`.
ParameterTypeDescription

typeName

String

Name of the Struct type to create.

properties

List<Object>

Properties to pass to the database.

java.util.List

List<Object>

The return value is an immutable list that holds all the information for creating a struct later.

> [!NOTE] If you have existing Mule apps that use the deprecated functions, replace `createStruct` > with `prepareStruct` and `createArray` with `prepareArray`. Additionally, remove the first > parameter `configName` from the function structure. ## Create the UDTs, the Table and the Stored Procedure Before configuring the Oracle database connection and creating the Mule application, use your desired SQL client tool to run an `.sql` script that creates in the database, these UDTs: 1. `PEOPLE` 2. `PERSON` 3. `PHONE_NUMBER` 4. `PHONE_NUMBER_ARRAY` 5. `PHONE_BOOK` Because some UDTs contain others, the order in which they are defined is important. For example, the object type `PERSON` must be defined before its member `PHONE_NUMBER_ARRAY` is defined. The script also creates a table called `HUMANS` and a stored procedure called `PROC_INSERT_HUMANS`. This stored procedure is intended to receive as an input parameter an object of type `PEOPLE`, from which it takes all the people whose age is less than 100 and inserts them into the table `HUMANS`. The stored procedure also defines an output parameter of type `PHONE_BOOK` that comprises a list of the phone numbers of all the people previously inserted into the `HUMANS` table The script that runs to create these UDTs, the table, and the stored procedure is as follows: ```xml --CREATE CUSTOM DATA TYPES (UDTs) CREATE OR REPLACE TYPE PHONE_NUMBER AS object(areaCode VARCHAR2(10), phoneNumber VARCHAR2(20)); CREATE OR REPLACE TYPE PHONE_NUMBER_ARRAY AS VARRAY(10) OF PHONE_NUMBER; CREATE OR REPLACE TYPE PERSON IS OBJECT(firstName VARCHAR(50), surname VARCHAR(50), age NUMBER, phoneNumbers PHONE_NUMBER_ARRAY); CREATE OR REPLACE TYPE PEOPLE IS TABLE OF PERSON; CREATE OR REPLACE TYPE PHONE_BOOK AS VARRAY(10) OF VARCHAR2(200); --CREATE TABLE HUMANS; CREATE TABLE HUMANS( firstName VARCHAR(50), surname VARCHAR(50), age NUMBER, phoneNumbers PHONE_NUMBER_ARRAY ); --CREATE STORED PROCEDURE create or replace procedure PROC_INSERT_HUMANS(people IN PEOPLE, contactList OUT PHONE_BOOK) IS phoneBook PHONE_BOOK := PHONE_BOOK(); BEGIN FOR idx IN people.first .. people.last LOOP IF people(idx).age < 100 THEN INSERT INTO HUMANS(firstName, surname, age, phoneNumbers) VALUES(people(idx).firstName, people(idx).surname, people(idx).age, people(idx).phoneNumbers); END IF; END LOOP; FOR humanContact IN (SELECT * FROM HUMANS h, TABLE(h.phoneNumbers) n) LOOP phoneBook.EXTEND(1); phoneBook(phoneBook.COUNT) := humanContact.surname || ',' || humanContact.firstname || ':' || humanContact.areaCode ||'-'|| humanContact.phoneNumber; END LOOP; contactList := phonebook; COMMIT; END PROC_INSERT_HUMANS; ``` ## Configure an Oracle Database Connection After you create your UDTs, the table and stored procedure in the Oracle database, go to Anypoint Studio to configure the Oracle database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, set the following parameters: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set the **Name** field to `dbConfig`. 10. In the **Connection** field, select **Oracle Connection**. 11. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Installs the library by using a local file. - **Add Maven dependency** Installs a Maven dependency to add to the project. 12. In the **Connection** section, set the following parameters: - **Host**: `localhost` - **Port**: `1521` - **User**: `SYS as SYSDBA` - **Password**: `Oradoc_db1` - **Instance**: `ORCLCDB` 13. On the **Advanced** tab, set the **Column types** field to **Edit inline**. 14. Click the plus sign (**+**) to add new column types to list all the UDTs that were previously created. 15. Specify the following values in the **Id** and **Type name** fields:
IdType name

2003

PEOPLE

2003

PHONE_NUMBER

2008

PERSON

2003

PHONE_ARRAY

2003

PHONE_BOOK

16. Click **Finish** to close the **Column type** window. 17. Click **Test Connection** to confirm that Mule can connect to the database. 18. Click **OK**. The following screenshot shows the HTTP Listener global element configuration in Studio: ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracleudt-example-1.png) Figure 2. HTTP Listener configuration The following screenshots show the Database global element configuration in Studio: ![The database global element configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracleudt-example-2.png) Figure 3. Database Config General configuration ![The database global element advanced configuration setting the Column types field](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracleudt-example-3.png) Figure 4. Database Config Advanced configuration ## Create, Run and Test the Mule Application After you configure the Oracle database connection, create, run an test the Mule application to call the stored procedure. ### Configure the HTTP Listener and Set Payload Component To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select `HTTP_Listener_config` global configuration. 3. Set the **Path** field to `/oracle`. 4. Drag a **Set Payload** component to the right of **Listener**. This component creates a list of items to send to the stored procedure for processing. 5. In the **Value** field, specify items to be listed: ```xml [{'name':'Anthony J', 'surname':'Crowley', 'age': 6000, 'phoneNumber': {'areaCode':'020', 'phoneNumber': '777'}}, {'name':'A.Z', 'surname':'Fell', 'age': 6000, 'phoneNumber':{'areaCode':'020', 'phoneNumber': '888'}}, {'name':'Adam', 'surname':'Young', 'age': 11, 'phoneNumber':{'areaCode':'046', 'phoneNumber': '666'}}, {'name':'Anathema', 'surname':'Device', 'age': 27, 'phoneNumber':{'areaCode':'020', 'phoneNumber': '123'}}, ] ``` 6. Set the **Mime Type** field to `application/java`. ![The Set payload component configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracleudt-example-4.png) Figure 5. Set Payload configuration ### Configure the Transform Message Component with DataWeave Functions Continue creating the Mule application using a **Transform Message** component with `prepareStruct` and `prepareArray` DataWeave functions that map application data to the example custom user data types: 1. Drag a **Transform Message** component to the right of **Set Payload**. This component transforms the JSON objects into an object that can be mapped to the data type `PEOPLE` that the stored procedure expects as an input parameter. 2. Double-click the component in the Studio canvas and set the name to `Transform Message - Prepare UDT`. 3. In the **Output** source code view of the component, click the **Edit Current Target** button. 4. In the **Selection dialog** box, set the **Output** field to `Variable` and the **Variable name** to `in_people_tab`, and then click **OK**. 5. In the **Output** field, specify the following DataWeave expression that contains the `prepareStruct` and `prepareArray` functions: ```DataWeave %dw 2.0 output application/java fun toPhoneNumberArray(phoneNumber) = Db::prepareArray("PHONE_NUMBER_ARRAY",[Db::prepareStruct("PHONE_NUMBER", [phoneNumber.areaCode, phoneNumber.phoneNumber])]) fun toPerson(person) = Db::prepareStruct("PERSON", [person.name, person.surname, person.age, toPhoneNumberArray(person.phoneNumber)]) --- Db::prepareArray("PEOPLE", payload map (item, index) -> ( toPerson(item) ) ) ``` ![Transform Message configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracleudt-example-6.png) Figure 6. Transform Message configuration The `prepareStruct` instructs Mule to create JDBC struct objects based on the `Name` type and their corresponding properties when a database operation is performed. In the example, types `PERSON` and `PHONE_NUMBER` are struct objects. The function expects the following parameters in order: - `typeName` A string with the name of the `Struct` type to create: in this example, `PERSON` or `PHONE_NUMBER` - `values` An array of values that conforms to the `Struct` properties: in this example, for `PHONE_NUMBER`, `['046', '666']` When the Mule app performs a Database Connector operation, the `prepareArray` function instructs Mule to create JDBC array objects based on the `Array` type. In this example, types `PHONE_NUMBER_ARRAY`, `PEOPLE`, and `PHONE_BOOK` are array objects. The function expects the following parameters in order: - `typeName` A string with the name of the `Array` type to create: in this example, `PEOPLE` or `PHONE_NUMBER_ARRAY` - `values` An array of values that conforms to the `Array` type: in this example, is an array of arrays, each of those representing `PERSON` objects, created using the `prepareStruct` function Both `prepareStruct` and `prepareArray` functions return special arrays that hold all the information to create the requested SQL values. At operation time the parameter data is recursively analyzed and these arrays are replaced with the proper SQL object. Note that you can combine and use these functions to create subtypes or nested types. In this example, the type `PERSON` contains the `PHONE_NUMBER_ARRAY` objects. At the same time, the type `PHONE_NUMBER_ARRAY` is defined as an array of `PHONE_NUMBER`. Additionally, you can combine these functions for complex types if you use the `prepareArray` function when you are matching to a UDT based on the `Array` type. ### Configure the Stored Procedure Operation Use the Database Connector **Stored Procedure** operation to call the Oracle stored procedure with UDTs: 1. Drag a **Stored procedure** operation to the right of **Transform Message**. This operation calls the stored procedure using Database Connector. 2. In the **Connector configuration** field, select `dbConfig` global configuration. 3. In the **SQL Query Text** field, enter `{ call proc_insert_humans(:people, :phoneBook) }`. 4. In the **Input Parameters** field, enter `{ people: vars.in_people_tab}` This step maps the output of the transformation, which is stored in the variable called `in_people_tab` to the input parameter. 5. In the **Output Parameters** field, select `Edit inline` and click the plus sign (**+**) to set a custom parameter: - **Key**: `phoneBook` - **Custom type**: `PHONE_BOOK` ![Stored procedure configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracleudt-example-5.png) Figure 7. Stored procedure configuration 6. Drag a second **Transform Message** component to the right of **Stored procedure**. 7. Double-click the component in the Studio canvas and set the name to `Transform Message - response to JSON`. 8. In the **Output** source code view of the component, set the following DataWeave expression: ```DataWeave %dw 2.0 output application/json --- payload ``` ### Run and Test the Mule Application To complete and test the Mule application: 1. Save the project in Studio. 2. Test the app by using the following curl command in your terminal: `curl localhost:8081/oracle`. The stored procedure should return the list of phone numbers of all the people added to the table `HUMANS`. ## XML for Calling Oracle Stored Procedure with UDTs Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ( toPerson(item) ) ) ]]> ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Call Oracle Stored Procedure That Uses User-Defined Types (UDT) Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Oracle enables you to create your custom data types, known as _user-defined types (UDTs)_. The following example shows how to configure Anypoint Connector for Database (Database Connector) **Stored procedure** operation in a Mule application to call a stored procedure that uses UDTs from an Oracle database. The stored procedure performs two actions: - Inserts the first name, last name, age, and phone number of people whose age is less than 100 into a table - Returns a list of phone numbers of all the people added to the table To accomplish this example, you must: - Run a script to create UDTs, the table, and the stored procedure - Configure an Oracle database connection - Create the Mule application - Use `prepareStruct` and `prepareArray` DataWeave functions to map application data to custom types - Run and test the application with curl commands ![The Oracle UDTs flow in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracle-udt-flow.png) Figure 1. Oracle Stored procedure with UDTs Flow ## Using prepareStruct and prepareArray Functions Previous Mule versions provided the `createStruct` and `createArray` functions, which are now deprecated. These functions created JDBC values right away, when they must have been created with the same connection used in the Database Connector operation. The new `prepareStruct` and `prepareArray` functions enable Database Connector to defer these JDBC values creation until the right SQL connection is available. The `createArray` and `createStruct` functions used to work only with an Oracle Connection provider. Now, the `preprareStruct` and `prepareArray` functions are compatible with all connection providers, such as the Generic Connection provider or the DataSource Reference connection provider for example, where you can successfully configure load balancing and fault tolerance URI for the connection.
Deprecated FunctionActive Function

Db::createArray(configName, typeName, values): java.sql.Array

Db::prepareArray(typeName, values): java.util.List

Db::createStruct(configName, typeName, properties): java.sql.Struct

Db::prepareStruct(typeName, properties): java.util.List

### Parameters The `Db::prepareArray(typeName, values): java.util.List` function prepares an array to send to the database as a `java.sql.Array`.
ParameterTypeDescription

typeName

String

Name of the Array type to create.

values

List<Object>

Values to pass to the database.

java.util.List

List<Object>

The return value is an immutable list that holds all the information for creating an array later.

The `Db::prepareStruct(typeName, properties): java.util.List` function prepares a `struct` to send to the database as a `java.sql.Struct`.
ParameterTypeDescription

typeName

String

Name of the Struct type to create.

properties

List<Object>

Properties to pass to the database.

java.util.List

List<Object>

The return value is an immutable list that holds all the information for creating a struct later.

> [!NOTE] If you have existing Mule apps that use the deprecated functions, replace `createStruct` > with `prepareStruct` and `createArray` with `prepareArray`. Additionally, remove the first > parameter `configName` from the function structure. ## Create the UDTs, the Table and the Stored Procedure Before configuring the Oracle database connection and creating the Mule application, use your desired SQL client tool to run an `.sql` script that creates in the database, these UDTs: 1. `PEOPLE` 2. `PERSON` 3. `PHONE_NUMBER` 4. `PHONE_NUMBER_ARRAY` 5. `PHONE_BOOK` Because some UDTs contain others, the order in which they are defined is important. For example, the object type `PERSON` must be defined before its member `PHONE_NUMBER_ARRAY` is defined. The script also creates a table called `HUMANS` and a stored procedure called `PROC_INSERT_HUMANS`. This stored procedure is intended to receive as an input parameter an object of type `PEOPLE`, from which it takes all the people whose age is less than 100 and inserts them into the table `HUMANS`. The stored procedure also defines an output parameter of type `PHONE_BOOK` that comprises a list of the phone numbers of all the people previously inserted into the `HUMANS` table The script that runs to create these UDTs, the table, and the stored procedure is as follows: ```xml --CREATE CUSTOM DATA TYPES (UDTs) CREATE OR REPLACE TYPE PHONE_NUMBER AS object(areaCode VARCHAR2(10), phoneNumber VARCHAR2(20)); CREATE OR REPLACE TYPE PHONE_NUMBER_ARRAY AS VARRAY(10) OF PHONE_NUMBER; CREATE OR REPLACE TYPE PERSON IS OBJECT(firstName VARCHAR(50), surname VARCHAR(50), age NUMBER, phoneNumbers PHONE_NUMBER_ARRAY); CREATE OR REPLACE TYPE PEOPLE IS TABLE OF PERSON; CREATE OR REPLACE TYPE PHONE_BOOK AS VARRAY(10) OF VARCHAR2(200); --CREATE TABLE HUMANS; CREATE TABLE HUMANS( firstName VARCHAR(50), surname VARCHAR(50), age NUMBER, phoneNumbers PHONE_NUMBER_ARRAY ); --CREATE STORED PROCEDURE create or replace procedure PROC_INSERT_HUMANS(people IN PEOPLE, contactList OUT PHONE_BOOK) IS phoneBook PHONE_BOOK := PHONE_BOOK(); BEGIN FOR idx IN people.first .. people.last LOOP IF people(idx).age < 100 THEN INSERT INTO HUMANS(firstName, surname, age, phoneNumbers) VALUES(people(idx).firstName, people(idx).surname, people(idx).age, people(idx).phoneNumbers); END IF; END LOOP; FOR humanContact IN (SELECT * FROM HUMANS h, TABLE(h.phoneNumbers) n) LOOP phoneBook.EXTEND(1); phoneBook(phoneBook.COUNT) := humanContact.surname || ',' || humanContact.firstname || ':' || humanContact.areaCode ||'-'|| humanContact.phoneNumber; END LOOP; contactList := phonebook; COMMIT; END PROC_INSERT_HUMANS; ``` ## Configure an Oracle Database Connection After you create your UDTs, the table and stored procedure in the Oracle database, go to Anypoint Studio to configure the Oracle database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, set the following parameters: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set the **Name** field to `dbConfig`. 10. In the **Connection** field, select **Oracle Connection**. 11. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Installs the library by using a local file. - **Add Maven dependency** Installs a Maven dependency to add to the project. 12. In the **Connection** section, set the following parameters: - **Host**: `localhost` - **Port**: `1521` - **User**: `SYS as SYSDBA` - **Password**: `Oradoc_db1` - **Instance**: `ORCLCDB` 13. On the **Advanced** tab, set the **Column types** field to **Edit inline**. 14. Click the plus sign (**+**) to add new column types to list all the UDTs that were previously created. 15. Specify the following values in the **Id** and **Type name** fields:
IdType name

2003

PEOPLE

2003

PHONE_NUMBER

2008

PERSON

2003

PHONE_ARRAY

2003

PHONE_BOOK

16. Click **Finish** to close the **Column type** window. 17. Click **Test Connection** to confirm that Mule can connect to the database. 18. Click **OK**. The following screenshot shows the HTTP Listener global element configuration in Studio: ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracleudt-example-1.png) Figure 2. HTTP Listener configuration The following screenshots show the Database global element configuration in Studio: ![The database global element configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracleudt-example-2.png) Figure 3. Database Config General configuration ![The database global element advanced configuration setting the Column types field](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracleudt-example-3.png) Figure 4. Database Config Advanced configuration ## Create, Run and Test the Mule Application After you configure the Oracle database connection, create, run an test the Mule application to call the stored procedure. ### Configure the HTTP Listener and Set Payload Component To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select `HTTP_Listener_config` global configuration. 3. Set the **Path** field to `/oracle`. 4. Drag a **Set Payload** component to the right of **Listener**. This component creates a list of items to send to the stored procedure for processing. 5. In the **Value** field, specify items to be listed: ```xml [{'name':'Anthony J', 'surname':'Crowley', 'age': 6000, 'phoneNumber': {'areaCode':'020', 'phoneNumber': '777'}}, {'name':'A.Z', 'surname':'Fell', 'age': 6000, 'phoneNumber':{'areaCode':'020', 'phoneNumber': '888'}}, {'name':'Adam', 'surname':'Young', 'age': 11, 'phoneNumber':{'areaCode':'046', 'phoneNumber': '666'}}, {'name':'Anathema', 'surname':'Device', 'age': 27, 'phoneNumber':{'areaCode':'020', 'phoneNumber': '123'}}, ] ``` 6. Set the **Mime Type** field to `application/java`. ![The Set payload component configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracleudt-example-4.png) Figure 5. Set Payload configuration ### Configure the Transform Message Component with DataWeave Functions Continue creating the Mule application using a **Transform Message** component with `prepareStruct` and `prepareArray` DataWeave functions that map application data to the example custom user data types: 1. Drag a **Transform Message** component to the right of **Set Payload**. This component transforms the JSON objects into an object that can be mapped to the data type `PEOPLE` that the stored procedure expects as an input parameter. 2. Double-click the component in the Studio canvas and set the name to `Transform Message - Prepare UDT`. 3. In the **Output** source code view of the component, click the **Edit Current Target** button. 4. In the **Selection dialog** box, set the **Output** field to `Variable` and the **Variable name** to `in_people_tab`, and then click **OK**. 5. In the **Output** field, specify the following DataWeave expression that contains the `prepareStruct` and `prepareArray` functions: ```DataWeave %dw 2.0 output application/java fun toPhoneNumberArray(phoneNumber) = Db::prepareArray("PHONE_NUMBER_ARRAY",[Db::prepareStruct("PHONE_NUMBER", [phoneNumber.areaCode, phoneNumber.phoneNumber])]) fun toPerson(person) = Db::prepareStruct("PERSON", [person.name, person.surname, person.age, toPhoneNumberArray(person.phoneNumber)]) --- Db::prepareArray("PEOPLE", payload map (item, index) -> ( toPerson(item) ) ) ``` ![Transform Message configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracleudt-example-6.png) Figure 6. Transform Message configuration The `prepareStruct` instructs Mule to create JDBC struct objects based on the `Name` type and their corresponding properties when a database operation is performed. In the example, types `PERSON` and `PHONE_NUMBER` are struct objects. The function expects the following parameters in order: - `typeName` A string with the name of the `Struct` type to create: in this example, `PERSON` or `PHONE_NUMBER` - `values` An array of values that conforms to the `Struct` properties: in this example, for `PHONE_NUMBER`, `['046', '666']` When the Mule app performs a Database Connector operation, the `prepareArray` function instructs Mule to create JDBC array objects based on the `Array` type. In this example, types `PHONE_NUMBER_ARRAY`, `PEOPLE`, and `PHONE_BOOK` are array objects. The function expects the following parameters in order: - `typeName` A string with the name of the `Array` type to create: in this example, `PEOPLE` or `PHONE_NUMBER_ARRAY` - `values` An array of values that conforms to the `Array` type: in this example, is an array of arrays, each of those representing `PERSON` objects, created using the `prepareStruct` function Both `prepareStruct` and `prepareArray` functions return special arrays that hold all the information to create the requested SQL values. At operation time the parameter data is recursively analyzed and these arrays are replaced with the proper SQL object. Note that you can combine and use these functions to create subtypes or nested types. In this example, the type `PERSON` contains the `PHONE_NUMBER_ARRAY` objects. At the same time, the type `PHONE_NUMBER_ARRAY` is defined as an array of `PHONE_NUMBER`. Additionally, you can combine these functions for complex types if you use the `prepareArray` function when you are matching to a UDT based on the `Array` type. ### Configure the Stored Procedure Operation Use the Database Connector **Stored Procedure** operation to call the Oracle stored procedure with UDTs: 1. Drag a **Stored procedure** operation to the right of **Transform Message**. This operation calls the stored procedure using Database Connector. 2. In the **Connector configuration** field, select `dbConfig` global configuration. 3. In the **SQL Query Text** field, enter `{ call proc_insert_humans(:people, :phoneBook) }`. 4. In the **Input Parameters** field, enter `{ people: vars.in_people_tab}` This step maps the output of the transformation, which is stored in the variable called `in_people_tab` to the input parameter. 5. In the **Output Parameters** field, select `Edit inline` and click the plus sign (**+**) to set a custom parameter: - **Key**: `phoneBook` - **Custom type**: `PHONE_BOOK` ![Stored procedure configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracleudt-example-5.png) Figure 7. Stored procedure configuration 6. Drag a second **Transform Message** component to the right of **Stored procedure**. 7. Double-click the component in the Studio canvas and set the name to `Transform Message - response to JSON`. 8. In the **Output** source code view of the component, set the following DataWeave expression: ```DataWeave %dw 2.0 output application/json --- payload ``` ### Run and Test the Mule Application To complete and test the Mule application: 1. Save the project in Studio. 2. Test the app by using the following curl command in your terminal: `curl localhost:8081/oracle`. The stored procedure should return the list of phone numbers of all the people added to the table `HUMANS`. ## XML for Calling Oracle Stored Procedure with UDTs Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ( toPerson(item) ) ) ]]> ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Call Oracle Stored Procedure That Uses User-Defined Types (UDT) Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Oracle enables you to create your custom data types, known as _user-defined types (UDTs)_. The following example shows how to configure Anypoint Connector for Database (Database Connector) **Stored procedure** operation in a Mule application to call a stored procedure that uses UDTs from an Oracle database. The stored procedure performs two actions: - Inserts the first name, last name, age, and phone number of people whose age is less than 100 into a table - Returns a list of phone numbers of all the people added to the table To accomplish this example, you must: - Run a script to create UDTs, the table, and the stored procedure - Configure an Oracle database connection - Create the Mule application - Use `prepareStruct` and `prepareArray` DataWeave functions to map application data to custom types - Run and test the application with curl commands ![The Oracle UDTs flow in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-oracle-udt-flow.png) Figure 1. Oracle Stored procedure with UDTs Flow ## Using prepareStruct and prepareArray Functions Previous Mule versions provided the `createStruct` and `createArray` functions, which are now deprecated. These functions created JDBC values right away, when they must have been created with the same connection used in the Database Connector operation. The new `prepareStruct` and `prepareArray` functions enable Database Connector to defer these JDBC values creation until the right SQL connection is available. The `createArray` and `createStruct` functions used to work only with an Oracle Connection provider. Now, the `preprareStruct` and `prepareArray` functions are compatible with all connection providers, such as the Generic Connection provider or the DataSource Reference connection provider for example, where you can successfully configure load balancing and fault tolerance URI for the connection.
Deprecated FunctionActive Function

Db::createArray(configName, typeName, values): java.sql.Array

Db::prepareArray(typeName, values): java.util.List

Db::createStruct(configName, typeName, properties): java.sql.Struct

Db::prepareStruct(typeName, properties): java.util.List

### Parameters The `Db::prepareArray(typeName, values): java.util.List` function prepares an array to send to the database as a `java.sql.Array`.
ParameterTypeDescription

typeName

String

Name of the Array type to create.

values

List<Object>

Values to pass to the database.

java.util.List

List<Object>

The return value is an immutable list that holds all the information for creating an array later.

The `Db::prepareStruct(typeName, properties): java.util.List` function prepares a `struct` to send to the database as a `java.sql.Struct`.
ParameterTypeDescription

typeName

String

Name of the Struct type to create.

properties

List<Object>

Properties to pass to the database.

java.util.List

List<Object>

The return value is an immutable list that holds all the information for creating a struct later.

> [!NOTE] If you have existing Mule apps that use the deprecated functions, replace `createStruct` > with `prepareStruct` and `createArray` with `prepareArray`. Additionally, remove the first > parameter `configName` from the function structure. ## Create the UDTs, the Table and the Stored Procedure Before configuring the Oracle database connection and creating the Mule application, use your desired SQL client tool to run an `.sql` script that creates in the database, these UDTs: 1. `PEOPLE` 2. `PERSON` 3. `PHONE_NUMBER` 4. `PHONE_NUMBER_ARRAY` 5. `PHONE_BOOK` Because some UDTs contain others, the order in which they are defined is important. For example, the object type `PERSON` must be defined before its member `PHONE_NUMBER_ARRAY` is defined. The script also creates a table called `HUMANS` and a stored procedure called `PROC_INSERT_HUMANS`. This stored procedure is intended to receive as an input parameter an object of type `PEOPLE`, from which it takes all the people whose age is less than 100 and inserts them into the table `HUMANS`. The stored procedure also defines an output parameter of type `PHONE_BOOK` that comprises a list of the phone numbers of all the people previously inserted into the `HUMANS` table The script that runs to create these UDTs, the table, and the stored procedure is as follows: ```xml --CREATE CUSTOM DATA TYPES (UDTs) CREATE OR REPLACE TYPE PHONE_NUMBER AS object(areaCode VARCHAR2(10), phoneNumber VARCHAR2(20)); CREATE OR REPLACE TYPE PHONE_NUMBER_ARRAY AS VARRAY(10) OF PHONE_NUMBER; CREATE OR REPLACE TYPE PERSON IS OBJECT(firstName VARCHAR(50), surname VARCHAR(50), age NUMBER, phoneNumbers PHONE_NUMBER_ARRAY); CREATE OR REPLACE TYPE PEOPLE IS TABLE OF PERSON; CREATE OR REPLACE TYPE PHONE_BOOK AS VARRAY(10) OF VARCHAR2(200); --CREATE TABLE HUMANS; CREATE TABLE HUMANS( firstName VARCHAR(50), surname VARCHAR(50), age NUMBER, phoneNumbers PHONE_NUMBER_ARRAY ); --CREATE STORED PROCEDURE create or replace procedure PROC_INSERT_HUMANS(people IN PEOPLE, contactList OUT PHONE_BOOK) IS phoneBook PHONE_BOOK := PHONE_BOOK(); BEGIN FOR idx IN people.first .. people.last LOOP IF people(idx).age < 100 THEN INSERT INTO HUMANS(firstName, surname, age, phoneNumbers) VALUES(people(idx).firstName, people(idx).surname, people(idx).age, people(idx).phoneNumbers); END IF; END LOOP; FOR humanContact IN (SELECT * FROM HUMANS h, TABLE(h.phoneNumbers) n) LOOP phoneBook.EXTEND(1); phoneBook(phoneBook.COUNT) := humanContact.surname || ',' || humanContact.firstname || ':' || humanContact.areaCode ||'-'|| humanContact.phoneNumber; END LOOP; contactList := phonebook; COMMIT; END PROC_INSERT_HUMANS; ``` ## Configure an Oracle Database Connection After you create your UDTs, the table and stored procedure in the Oracle database, go to Anypoint Studio to configure the Oracle database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, set the following parameters: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set the **Name** field to `dbConfig`. 10. In the **Connection** field, select **Oracle Connection**. 11. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Installs the library by using a local file. - **Add Maven dependency** Installs a Maven dependency to add to the project. 12. In the **Connection** section, set the following parameters: - **Host**: `localhost` - **Port**: `1521` - **User**: `SYS as SYSDBA` - **Password**: `Oradoc_db1` - **Instance**: `ORCLCDB` 13. On the **Advanced** tab, set the **Column types** field to **Edit inline**. 14. Click the plus sign (**+**) to add new column types to list all the UDTs that were previously created. 15. Specify the following values in the **Id** and **Type name** fields:
IdType name

2003

PEOPLE

2003

PHONE_NUMBER

2008

PERSON

2003

PHONE_ARRAY

2003

PHONE_BOOK

16. Click **Finish** to close the **Column type** window. 17. Click **Test Connection** to confirm that Mule can connect to the database. 18. Click **OK**. The following screenshot shows the HTTP Listener global element configuration in Studio: ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-oracleudt-example-1.png) Figure 2. HTTP Listener configuration The following screenshots show the Database global element configuration in Studio: ![The database global element configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/latest/_images/database-oracleudt-example-2.png) Figure 3. Database Config General configuration ![The database global element advanced configuration setting the Column types field](/mulesoft/current/en-us/db-connector/latest/_images/database-oracleudt-example-3.png) Figure 4. Database Config Advanced configuration ## Create, Run and Test the Mule Application After you configure the Oracle database connection, create, run an test the Mule application to call the stored procedure. ### Configure the HTTP Listener and Set Payload Component To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select `HTTP_Listener_config` global configuration. 3. Set the **Path** field to `/oracle`. 4. Drag a **Set Payload** component to the right of **Listener**. This component creates a list of items to send to the stored procedure for processing. 5. In the **Value** field, specify items to be listed: ```xml [{'name':'Anthony J', 'surname':'Crowley', 'age': 6000, 'phoneNumber': {'areaCode':'020', 'phoneNumber': '777'}}, {'name':'A.Z', 'surname':'Fell', 'age': 6000, 'phoneNumber':{'areaCode':'020', 'phoneNumber': '888'}}, {'name':'Adam', 'surname':'Young', 'age': 11, 'phoneNumber':{'areaCode':'046', 'phoneNumber': '666'}}, {'name':'Anathema', 'surname':'Device', 'age': 27, 'phoneNumber':{'areaCode':'020', 'phoneNumber': '123'}}, ] ``` 6. Set the **Mime Type** field to `application/java`. ![The Set payload component configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-oracleudt-example-4.png) Figure 5. Set Payload configuration ### Configure the Transform Message Component with DataWeave Functions Continue creating the Mule application using a **Transform Message** component with `prepareStruct` and `prepareArray` DataWeave functions that map application data to the example custom user data types: 1. Drag a **Transform Message** component to the right of **Set Payload**. This component transforms the JSON objects into an object that can be mapped to the data type `PEOPLE` that the stored procedure expects as an input parameter. 2. Double-click the component in the Studio canvas and set the name to `Transform Message - Prepare UDT`. 3. In the **Output** source code view of the component, click the **Edit Current Target** button. 4. In the **Selection dialog** box, set the **Output** field to `Variable` and the **Variable name** to `in_people_tab`, and then click **OK**. 5. In the **Output** field, specify the following DataWeave expression that contains the `prepareStruct` and `prepareArray` functions: ```DataWeave %dw 2.0 output application/java fun toPhoneNumberArray(phoneNumber) = Db::prepareArray("PHONE_NUMBER_ARRAY",[Db::prepareStruct("PHONE_NUMBER", [phoneNumber.areaCode, phoneNumber.phoneNumber])]) fun toPerson(person) = Db::prepareStruct("PERSON", [person.name, person.surname, person.age, toPhoneNumberArray(person.phoneNumber)]) --- Db::prepareArray("PEOPLE", payload map (item, index) -> ( toPerson(item) ) ) ``` ![Transform Message configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-oracleudt-example-6.png) Figure 6. Transform Message configuration The `prepareStruct` instructs Mule to create JDBC struct objects based on the `Name` type and their corresponding properties when a database operation is performed. In the example, types `PERSON` and `PHONE_NUMBER` are struct objects. The function expects the following parameters in order: - `typeName` A string with the name of the `Struct` type to create: in this example, `PERSON` or `PHONE_NUMBER` - `values` An array of values that conforms to the `Struct` properties: in this example, for `PHONE_NUMBER`, `['046', '666']` When the Mule app performs a Database Connector operation, the `prepareArray` function instructs Mule to create JDBC array objects based on the `Array` type. In this example, types `PHONE_NUMBER_ARRAY`, `PEOPLE`, and `PHONE_BOOK` are array objects. The function expects the following parameters in order: - `typeName` A string with the name of the `Array` type to create: in this example, `PEOPLE` or `PHONE_NUMBER_ARRAY` - `values` An array of values that conforms to the `Array` type: in this example, is an array of arrays, each of those representing `PERSON` objects, created using the `prepareStruct` function Both `prepareStruct` and `prepareArray` functions return special arrays that hold all the information to create the requested SQL values. At operation time the parameter data is recursively analyzed and these arrays are replaced with the proper SQL object. Note that you can combine and use these functions to create subtypes or nested types. In this example, the type `PERSON` contains the `PHONE_NUMBER_ARRAY` objects. At the same time, the type `PHONE_NUMBER_ARRAY` is defined as an array of `PHONE_NUMBER`. Additionally, you can combine these functions for complex types if you use the `prepareArray` function when you are matching to a UDT based on the `Array` type. ### Configure the Stored Procedure Operation Use the Database Connector **Stored Procedure** operation to call the Oracle stored procedure with UDTs: 1. Drag a **Stored procedure** operation to the right of **Transform Message**. This operation calls the stored procedure using Database Connector. 2. In the **Connector configuration** field, select `dbConfig` global configuration. 3. In the **SQL Query Text** field, enter `{ call proc_insert_humans(:people, :phoneBook) }`. 4. In the **Input Parameters** field, enter `{ people: vars.in_people_tab}` This step maps the output of the transformation, which is stored in the variable called `in_people_tab` to the input parameter. 5. In the **Output Parameters** field, select `Edit inline` and click the plus sign (**+**) to set a custom parameter: - **Key**: `phoneBook` - **Custom type**: `PHONE_BOOK` ![Stored procedure configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-oracleudt-example-5.png) Figure 7. Stored procedure configuration 6. Drag a second **Transform Message** component to the right of **Stored procedure**. 7. Double-click the component in the Studio canvas and set the name to `Transform Message - response to JSON`. 8. In the **Output** source code view of the component, set the following DataWeave expression: ```DataWeave %dw 2.0 output application/json --- payload ``` ### Run and Test the Mule Application To complete and test the Mule application: 1. Save the project in Studio. 2. Test the app by using the following curl command in your terminal: `curl localhost:8081/oracle`. The stored procedure should return the list of phone numbers of all the people added to the table `HUMANS`. ## XML for Calling Oracle Stored Procedure with UDTs Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ( toPerson(item) ) ) ]]> ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure a Database Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) can connect to any database for which a JDBC driver is available. The following examples show how to connect to the most popular databases such as Derby, Microsoft SQL Server, MySQL, Oracle, and a generic database. Additionally, for advanced uses cases, there are examples showing how to connect to a global data source, configure a JDBC driver, configure connection pooling, and connect to an Oracle database with TNS, both in Anypoint Studio and the XML editor. ## Configure a Data Source Reference Connection Database Connector generates a JDBC data source by using the parameter values you provide when you configure the **Generic Connection** field. If you want to create your own data source and use it to connect to a database, configure the **Data Source Reference Connection** field. The following example shows how to use Anypoint Studio to configure a data source reference connection to a Derby database: 1. In Studio, in the `src/main/resources` folder, create a `datasource-config.xml` bean file to define a custom `enhydra` data source that connects to a Derby database: datasource-config.xml File ```xml ``` 2. Return to your Mule flow, go to the **Global Elements** view, and click **Create** to open the **Choose Global Type** window. 3. In the **Filter** field, type `spring`, select **Spring Config**, and click **OK**. 4. In the **Spring Config** window **Files** field, add `datasource-config.xml` to reference the spring configuration file with the Spring module. 5. Click **OK**. The following screenshot shows the configuration: ![Spring Configuration Data Source](/mulesoft/current/en-us/db-connector/1.14/_images/database-spring-configuration.png) Figure 1. Spring Configuration Data Source 6. In the **Global Elements** view, click **Create** to open the **Choose Global Type** window. 7. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 8. In the **Database Config** window, for the **Connection** field, select **Data Source Reference Connection**. 9. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 10. For **Data source ref**, add the bean ID `jdbcDataSource` created in the `datasource-config.xml` bean file. 11. Click **Test Connection** to confirm that Mule can connect to the database. 12. Click **OK**. The following screenshot shows the configuration: ![The Data Source Reference Connection global configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-datasource-connection.png) Figure 2. Data Source Reference Connection In the XML editor, both the spring and database configurations look like this: ```xml ``` ## Configure a Data Source Reference Connection When in XA Transaction Mode If your Mule app requires operations bound to XA transactions, and connection pooling is enabled for the database configuration in use, the default connection pool implementation for Data Source Reference Connection is Enhydra XAPool. Enhydra XAPool does not support prepared statements. To execute these operations use the Bitronix connection pool. Refer to [Configuring the Bitronix Transaction Manager](https://docs.mulesoft.com/mule-runtime/latest/using-bitronix-to-manage-transactions#configuring-the-bitronix-transaction-manager) documentation for details. > [!NOTE] When using XA transactions, you must provide an `XADataSource` object in the JDBC data > source spring bean configuration file of your app. The following example shows how to configure a **Data Source Reference Connection** for a Derby database when in XA transaction mode: 1. In Studio, in the `src/main/resources` folder, create a `datasource-config.xml` spring bean file. 2. Add the `XADataSource` object to the end of the class `org.enhydra.jdbc.standard.Standard`, for example, `class="org.enhydra.jdbc.standard.StandardXaDataSource`: datasource-config.xml File ```xml ``` 3. Return to your Mule flow and navigate to **Global Elements** > **Create** to open the **Choose Global Type** window. 4. In **Filter**, type `spring`, select **Spring Config**, and click **OK**. 5. In **Spring Config** > **Files**, add `datasource-config.xml` to reference the Spring configuration file with the Spring module. 6. Click **OK**. ![Spring Configuration window with datasource-config.xml configure in Files field](/mulesoft/current/en-us/db-connector/1.14/_images/database-spring-configuration.png) 8. In **Global Elements**, click **Create** to open the **Choose Global Type** window. 9. In **Filter**, type `database`, select **Database Config**, and click **OK**. 10. In **Database Config** > **Connection**, select **Data Source Reference Connection**. 11. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. For **Data source ref**, add the bean ID `jdbcDataSource` created in the `datasource-config.xml` bean file. 13. In the **Advanced** tab, configure the **Pooling profile**, **Column types**, and **Reconnection** fields. 14. Click **Test Connection** to confirm that Mule can connect to the database. 15. Click **OK**. In the XML editor, both the Spring and database configurations look like this: ```xml ``` ## Configure a Derby Connection Use the **Derby Connection** field type to connect to a Derby database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Derby Connection**. 5. Click **Configure** to add the required Derby JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Database** to `derbyDB` and **Subsub protocol** to `directory`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Derby Connection global configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-derby-connection.png) Figure 3. Derby Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a Generic Connection Use the **Generic Connection** field type to connect to: - A database for which MuleSoft does not provide a specific connection type - A supported database in which you are using custom options that are not included in the connection types The following example shows how to connect to an H2 database in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**,and click **OK**. 4. In the **Database Config** window, for the **Connection** field select **Generic Connection**. 5. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **URL** to `jdbc:h2:file:/tmp/datasenseDBand` and **Driver class name** to `org.h2.Driver`. 7. Click **Test Connection** to validate the connection with the database. 8. Click **OK**. The following screenshot shows the configuration in Studio: ![The Generic Connection global configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-generic-connection.png) Figure 4. Generic Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a Microsoft SQL Server Connection Use the **Microsoft SQL Server Connection** field type to connect to a Microsoft SQL Server database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Microsoft SQL Server Connection**. 5. Click **Configure** to add the required Microsoft SQL Server driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `0.0.0.0`, **Port** to `553`, **User** to `Max`, **Password** to `password` and **Database name** to `microsoftDB`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Microsoft SQL Server Connection global configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-mssql-connection.png) Figure 5. Microsoft SQL Server Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a MySQL Database Connection Use the **MySQL Connection** field type to connect to a MySQL database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **MySQL Connection**. 5. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `0.0.0.0`, **Port** to `3306`, **User** to `Max`, **Password** to `password`, and **Database** to `someSchema`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The MySQL Connection global configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-mysql-connection.png) Figure 6. MySQL Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure an Oracle Connection Use the **Oracle Connection** field type to connect to an Oracle database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Oracle Connection**. 5. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `192.168.99.100`, **Port** to `1521`, **User** to `system`, **Password** to `oracle`, and **Instance** to `xe`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Oracle Connection global configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracle-connection.png) Figure 7. Oracle Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure the JDBC Driver After you configure the connections, add the JDBC driver. The following example shows how to add a driver for the MySQL database: 1. In Studio, add the driver using either of the following options: - In the **Database Config** window, click **Configure**, select **Add Maven dependency**, and pick the dependency: ![Pick Maven dependency](/mulesoft/current/en-us/db-connector/1.14/_images/database-dependency.png) Figure 8. Pick Maven dependency - Add the dependency directly to your project’s `pom.xml` file: ```xml mysql mysql-connector-java 5.1.48 ``` 2. Configure your `pom.xml` file so that Mule exposes the driver dependency to Database Connector: ```xml org.mule.tools.maven mule-maven-plugin 1.0.0 mysql mysql-connector-java ``` ## Configure Connection Pools Establishing connections is costly in terms of connectors, the relational database management system (RDBMS) network, and processing overhead. Database Connector supports the use of pooling profiles that enable you to build a connection pool. This is a group of established connections that the connector can use to perform required operations without having to establish new connections every time. When you configure the **Pooling profile** field in the global element of your application, deselect the **Test connection on checkout** field to improve the connector performance with connection pooling. If you leave the field selected as default (`TRUE`), every time a connection is checked out of the pool, the connection pool performs connectivity checks against the database, which increases the time required for each operation to complete. All connection type configurations accept the **Pooling profile** field configuration. In JDBC, pooling occurs at the data source level, so to enable pooling, you have to configure the global data source. The following example shows how to configure a pooling profile for an Oracle database connection with the **Test connection on checkout** field set to `FALSE`: 1. In the **Database Config** window, in the **Advanced** tab, for **Pooling profile** select **Edit inline**. 2. Set the following fields: - **Max pool size**: `30` - **Min pool size**: `4` - **Acquire increment**: `1` - **Prepared statement cache size** `5` - **Max wait**: `0` - **Max wait unit**: `SECONDS (Default)` - **Max idle time** `60` - **Max statements** `0` 3. Deselect **Test connection on checkout**. This sets the field as `FALSE`. 4. For **Column types** select **Edit inline**. 5. Click the (**+**) plus sign to add a column type. 6. In the **Column type** window, set **Id** to `2003`, **Type name** to `1000`, and click **Finish**. 7. Repeat step 5. 8. To add a new column type, set **Id** to `2002`, **Type name** to `PHONE_NUMBER_ARRAY`, and click **Finish**. The following screenshot shows the configuration in Studio: ![The Pooling Profile field Configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-pooling-configuration.png) Figure 9. Pooling Profile Configuration In the XML editor, the `` and `testConnectionOnCheckout="false` configurations look like these: ```xml ``` ## Configure an Oracle Connection with TNS Names The following example shows how to configure the **Generic Connection** field to connect to an Oracle database that relies on the `tnsnames.ora` file. If a firewall separates your Mule runtime engine from the database, use the `ENABLE=BROKEN` parameter to enable a keep-alive connection at the TNS connection. If a keep-alive connection is not set, the connection can drop traffic due to expiring inactivity timers. 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Generic Connection**. 5. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set the connection **URL** to `jdbc:oracle:thin:${oracle.user}/${oracle.password}@(DESCRIPTION=(ENABLE=BROKEN)(FAILOVER=ON)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=${oracle.host1})(PORT=${oracle.port}))(ADDRESS=(PROTOCOL=TCP)(HOST=${oracle.host2})(PORT=${oracle.port})))(CONNECT_DATA=(SERVICE_NAME=${oracle.service})))`. 7. Set **Driver class name** to `oracle.jdbc.driver.OracleDriver`. 8. Click **Test Connection** to validate the connection with the database. 9. Click **OK**. The following screenshot shows the configuration in Studio: ![The Oracle database with TNS configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracle-tns.png) Figure 10. Oracle with TNS configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure Cache Query Template Size The following example shows how to configure the **Cache Query Template Size** field for the connection. 1. In Studio, open the Database Global Configuration window. 2. Select the **Advanced** tab. 3. Set the **Cache Query Template Size** field to your desired value. ![Cache Query Template Size field set to 50](/mulesoft/current/en-us/db-connector/1.14/_images/database-cachequery.png) ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure a Database Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) can connect to any database for which a JDBC driver is available. The following examples show how to connect to the most popular databases such as Derby, Microsoft SQL Server, MySQL, Oracle, and a generic database. Additionally, for advanced uses cases, there are examples showing how to connect to a global data source, configure a JDBC driver, configure connection pooling, and connect to an Oracle database with TNS, both in Anypoint Studio and the XML editor. ## Configure a Data Source Reference Connection Database Connector generates a JDBC data source by using the parameter values you provide when you configure the **Generic Connection** field. If you want to create your own data source and use it to connect to a database, configure the **Data Source Reference Connection** field. The following example shows how to use Anypoint Studio to configure a data source reference connection to a Derby database: 1. In Studio, in the `src/main/resources` folder, create a `datasource-config.xml` bean file to define a custom `enhydra` data source that connects to a Derby database: datasource-config.xml File ```xml ``` 2. Return to your Mule flow, go to the **Global Elements** view, and click **Create** to open the **Choose Global Type** window. 3. In the **Filter** field, type `spring`, select **Spring Config**, and click **OK**. 4. In the **Spring Config** window **Files** field, add `datasource-config.xml` to reference the spring configuration file with the Spring module. 5. Click **OK**. The following screenshot shows the configuration: ![Spring Configuration Data Source](/mulesoft/current/en-us/db-connector/1.15/_images/database-spring-configuration.png) Figure 1. Spring Configuration Data Source 6. In the **Global Elements** view, click **Create** to open the **Choose Global Type** window. 7. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 8. In the **Database Config** window, for the **Connection** field, select **Data Source Reference Connection**. 9. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 10. For **Data source ref**, add the bean ID `jdbcDataSource` created in the `datasource-config.xml` bean file. 11. Click **Test Connection** to confirm that Mule can connect to the database. 12. Click **OK**. The following screenshot shows the configuration: ![The Data Source Reference Connection global configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-datasource-connection.png) Figure 2. Data Source Reference Connection In the XML editor, both the spring and database configurations look like this: ```xml ``` ## Configure a Data Source Reference Connection When in XA Transaction Mode If your Mule app requires operations bound to XA transactions, and connection pooling is enabled for the database configuration in use, the default connection pool implementation for Data Source Reference Connection is Enhydra XAPool. Enhydra XAPool does not support prepared statements. To execute these operations use the Bitronix connection pool. Refer to [Configuring the Bitronix Transaction Manager](https://docs.mulesoft.com/mule-runtime/latest/using-bitronix-to-manage-transactions#configuring-the-bitronix-transaction-manager) documentation for details. > [!NOTE] When using XA transactions, you must provide an `XADataSource` object in the JDBC data > source spring bean configuration file of your app. The following example shows how to configure a **Data Source Reference Connection** for a Derby database when in XA transaction mode: 1. In Studio, in the `src/main/resources` folder, create a `datasource-config.xml` spring bean file. 2. Add the `XADataSource` object to the end of the class `org.enhydra.jdbc.standard.Standard`, for example, `class="org.enhydra.jdbc.standard.StandardXaDataSource`: datasource-config.xml File ```xml ``` 3. Return to your Mule flow and navigate to **Global Elements** > **Create** to open the **Choose Global Type** window. 4. In **Filter**, type `spring`, select **Spring Config**, and click **OK**. 5. In **Spring Config** > **Files**, add `datasource-config.xml` to reference the Spring configuration file with the Spring module. 6. Click **OK**. ![Spring Configuration window with datasource-config.xml configure in Files field](/mulesoft/current/en-us/db-connector/1.15/_images/database-spring-configuration.png) 8. In **Global Elements**, click **Create** to open the **Choose Global Type** window. 9. In **Filter**, type `database`, select **Database Config**, and click **OK**. 10. In **Database Config** > **Connection**, select **Data Source Reference Connection**. 11. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. For **Data source ref**, add the bean ID `jdbcDataSource` created in the `datasource-config.xml` bean file. 13. In the **Advanced** tab, configure the **Pooling profile**, **Column types**, and **Reconnection** fields. 14. Click **Test Connection** to confirm that Mule can connect to the database. 15. Click **OK**. In the XML editor, both the Spring and database configurations look like this: ```xml ``` ## Configure a Derby Connection Use the **Derby Connection** field type to connect to a Derby database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Derby Connection**. 5. Click **Configure** to add the required Derby JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Database** to `derbyDB` and **Subsub protocol** to `directory`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Derby Connection global configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-derby-connection.png) Figure 3. Derby Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a Generic Connection Use the **Generic Connection** field type to connect to: - A database for which MuleSoft does not provide a specific connection type - A supported database in which you are using custom options that are not included in the connection types The following example shows how to connect to an H2 database in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**,and click **OK**. 4. In the **Database Config** window, for the **Connection** field select **Generic Connection**. 5. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **URL** to `jdbc:h2:file:/tmp/datasenseDBand` and **Driver class name** to `org.h2.Driver`. 7. Click **Test Connection** to validate the connection with the database. 8. Click **OK**. The following screenshot shows the configuration in Studio: ![The Generic Connection global configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-generic-connection.png) Figure 4. Generic Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a Microsoft SQL Server Connection Use the **Microsoft SQL Server Connection** field type to connect to a Microsoft SQL Server database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Microsoft SQL Server Connection**. 5. Click **Configure** to add the required Microsoft SQL Server driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `0.0.0.0`, **Port** to `553`, **User** to `Max`, **Password** to `password` and **Database name** to `microsoftDB`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Microsoft SQL Server Connection global configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-mssql-connection.png) Figure 5. Microsoft SQL Server Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a MySQL Database Connection Use the **MySQL Connection** field type to connect to a MySQL database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **MySQL Connection**. 5. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `0.0.0.0`, **Port** to `3306`, **User** to `Max`, **Password** to `password`, and **Database** to `someSchema`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The MySQL Connection global configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-mysql-connection.png) Figure 6. MySQL Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure an Oracle Connection Use the **Oracle Connection** field type to connect to an Oracle database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Oracle Connection**. 5. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `192.168.99.100`, **Port** to `1521`, **User** to `system`, **Password** to `oracle`, and **Instance** to `xe`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Oracle Connection global configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracle-connection.png) Figure 7. Oracle Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure the JDBC Driver After you configure the connections, add the JDBC driver. The following example shows how to add a driver for the MySQL database: 1. In Studio, add the driver using either of the following options: - In the **Database Config** window, click **Configure**, select **Add Maven dependency**, and pick the dependency: ![Pick Maven dependency](/mulesoft/current/en-us/db-connector/1.15/_images/database-dependency.png) Figure 8. Pick Maven dependency - Add the dependency directly to your project’s `pom.xml` file: ```xml mysql mysql-connector-java 5.1.48 ``` 2. Configure your `pom.xml` file so that Mule exposes the driver dependency to Database Connector: ```xml org.mule.tools.maven mule-maven-plugin 1.0.0 mysql mysql-connector-java ``` ## Configure Connection Pools Establishing connections is costly in terms of connectors, the relational database management system (RDBMS) network, and processing overhead. Database Connector supports the use of pooling profiles that enable you to build a connection pool. This is a group of established connections that the connector can use to perform required operations without having to establish new connections every time. When you configure the **Pooling profile** field in the global element of your application, deselect the **Test connection on checkout** field to improve the connector performance with connection pooling. If you leave the field selected as default (`TRUE`), every time a connection is checked out of the pool, the connection pool performs connectivity checks against the database, which increases the time required for each operation to complete. All connection type configurations accept the **Pooling profile** field configuration. In JDBC, pooling occurs at the data source level, so to enable pooling, you have to configure the global data source. The following example shows how to configure a pooling profile for an Oracle database connection with the **Test connection on checkout** field set to `FALSE`: 1. In the **Database Config** window, in the **Advanced** tab, for **Pooling profile** select **Edit inline**. 2. Set the following fields: - **Max pool size**: `30` - **Min pool size**: `4` - **Acquire increment**: `1` - **Prepared statement cache size** `5` - **Max wait**: `0` - **Max wait unit**: `SECONDS (Default)` - **Max idle time** `60` - **Max statements** `0` 3. Deselect **Test connection on checkout**. This sets the field as `FALSE`. 4. For **Column types** select **Edit inline**. 5. Click the (**+**) plus sign to add a column type. 6. In the **Column type** window, set **Id** to `2003`, **Type name** to `1000`, and click **Finish**. 7. Repeat step 5. 8. To add a new column type, set **Id** to `2002`, **Type name** to `PHONE_NUMBER_ARRAY`, and click **Finish**. The following screenshot shows the configuration in Studio: ![The Pooling Profile field Configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-pooling-configuration.png) Figure 9. Pooling Profile Configuration In the XML editor, the `` and `testConnectionOnCheckout="false` configurations look like these: ```xml ``` ## Configure an Oracle Connection with TNS Names The following example shows how to configure the **Generic Connection** field to connect to an Oracle database that relies on the `tnsnames.ora` file. If a firewall separates your Mule runtime engine from the database, use the `ENABLE=BROKEN` parameter to enable a keep-alive connection at the TNS connection. If a keep-alive connection is not set, the connection can drop traffic due to expiring inactivity timers. 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Generic Connection**. 5. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set the connection **URL** to `jdbc:oracle:thin:${oracle.user}/${oracle.password}@(DESCRIPTION=(ENABLE=BROKEN)(FAILOVER=ON)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=${oracle.host1})(PORT=${oracle.port}))(ADDRESS=(PROTOCOL=TCP)(HOST=${oracle.host2})(PORT=${oracle.port})))(CONNECT_DATA=(SERVICE_NAME=${oracle.service})))`. 7. Set **Driver class name** to `oracle.jdbc.driver.OracleDriver`. 8. Click **Test Connection** to validate the connection with the database. 9. Click **OK**. The following screenshot shows the configuration in Studio: ![The Oracle database with TNS configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracle-tns.png) Figure 10. Oracle with TNS configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure Cache Query Template Size The following example shows how to configure the **Cache Query Template Size** field for the connection. 1. In Studio, open the Database Global Configuration window. 2. Select the **Advanced** tab. 3. Set the **Cache Query Template Size** field to your desired value. ![Cache Query Template Size field set to 50](/mulesoft/current/en-us/db-connector/1.15/_images/database-cachequery.png) ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure a Database Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) can connect to any database for which a JDBC driver is available. The following examples show how to connect to the most popular databases such as Derby, Microsoft SQL Server, MySQL, Oracle, and a generic database. Additionally, for advanced uses cases, there are examples showing how to connect to a global data source, configure a JDBC driver, configure connection pooling, and connect to an Oracle database with TNS, both in Anypoint Studio and the XML editor. ## Configure a Data Source Reference Connection Database Connector generates a JDBC data source by using the parameter values you provide when you configure the **Generic Connection** field. If you want to create your own data source and use it to connect to a database, configure the **Data Source Reference Connection** field. The following example shows how to use Anypoint Studio to configure a data source reference connection to a Derby database: 1. In Studio, in the `src/main/resources` folder, create a `datasource-config.xml` bean file to define a custom `enhydra` data source that connects to a Derby database: datasource-config.xml File ```xml ``` 2. Return to your Mule flow, go to the **Global Elements** view, and click **Create** to open the **Choose Global Type** window. 3. In the **Filter** field, type `spring`, select **Spring Config**, and click **OK**. 4. In the **Spring Config** window **Files** field, add `datasource-config.xml` to reference the spring configuration file with the Spring module. 5. Click **OK**. The following screenshot shows the configuration: ![Spring Configuration Data Source](/mulesoft/current/en-us/db-connector/latest/_images/database-spring-configuration.png) Figure 1. Spring Configuration Data Source 6. In the **Global Elements** view, click **Create** to open the **Choose Global Type** window. 7. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 8. In the **Database Config** window, for the **Connection** field, select **Data Source Reference Connection**. 9. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 10. For **Data source ref**, add the bean ID `jdbcDataSource` created in the `datasource-config.xml` bean file. 11. Click **Test Connection** to confirm that Mule can connect to the database. 12. Click **OK**. The following screenshot shows the configuration: ![The Data Source Reference Connection global configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-datasource-connection.png) Figure 2. Data Source Reference Connection In the XML editor, both the spring and database configurations look like this: ```xml ``` ## Configure a Data Source Reference Connection When in XA Transaction Mode If your Mule app requires operations bound to XA transactions, and connection pooling is enabled for the database configuration in use, the default connection pool implementation for Data Source Reference Connection is Enhydra XAPool. Enhydra XAPool does not support prepared statements. To execute these operations use the Bitronix connection pool. Refer to [Configuring the Bitronix Transaction Manager](https://docs.mulesoft.com/mule-runtime/latest/using-bitronix-to-manage-transactions#configuring-the-bitronix-transaction-manager) documentation for details. > [!NOTE] When using XA transactions, you must provide an `XADataSource` object in the JDBC data > source spring bean configuration file of your app. The following example shows how to configure a **Data Source Reference Connection** for a Derby database when in XA transaction mode: 1. In Studio, in the `src/main/resources` folder, create a `datasource-config.xml` spring bean file. 2. Add the `XADataSource` object to the end of the class `org.enhydra.jdbc.standard.Standard`, for example, `class="org.enhydra.jdbc.standard.StandardXaDataSource`: datasource-config.xml File ```xml ``` 3. Return to your Mule flow and navigate to **Global Elements** > **Create** to open the **Choose Global Type** window. 4. In **Filter**, type `spring`, select **Spring Config**, and click **OK**. 5. In **Spring Config** > **Files**, add `datasource-config.xml` to reference the Spring configuration file with the Spring module. 6. Click **OK**. ![Spring Configuration window with datasource-config.xml configure in Files field](/mulesoft/current/en-us/db-connector/latest/_images/database-spring-configuration.png) 8. In **Global Elements**, click **Create** to open the **Choose Global Type** window. 9. In **Filter**, type `database`, select **Database Config**, and click **OK**. 10. In **Database Config** > **Connection**, select **Data Source Reference Connection**. 11. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. For **Data source ref**, add the bean ID `jdbcDataSource` created in the `datasource-config.xml` bean file. 13. In the **Advanced** tab, configure the **Pooling profile**, **Column types**, and **Reconnection** fields. 14. Click **Test Connection** to confirm that Mule can connect to the database. 15. Click **OK**. In the XML editor, both the Spring and database configurations look like this: ```xml ``` ## Configure a Derby Connection Use the **Derby Connection** field type to connect to a Derby database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Derby Connection**. 5. Click **Configure** to add the required Derby JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Database** to `derbyDB` and **Subsub protocol** to `directory`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Derby Connection global configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-derby-connection.png) Figure 3. Derby Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a Generic Connection Use the **Generic Connection** field type to connect to: - A database for which MuleSoft does not provide a specific connection type - A supported database in which you are using custom options that are not included in the connection types The following example shows how to connect to an H2 database in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**,and click **OK**. 4. In the **Database Config** window, for the **Connection** field select **Generic Connection**. 5. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **URL** to `jdbc:h2:file:/tmp/datasenseDBand` and **Driver class name** to `org.h2.Driver`. 7. Click **Test Connection** to validate the connection with the database. 8. Click **OK**. The following screenshot shows the configuration in Studio: ![The Generic Connection global configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-generic-connection.png) Figure 4. Generic Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a Microsoft SQL Server Connection Use the **Microsoft SQL Server Connection** field type to connect to a Microsoft SQL Server database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Microsoft SQL Server Connection**. 5. Click **Configure** to add the required Microsoft SQL Server driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `0.0.0.0`, **Port** to `553`, **User** to `Max`, **Password** to `password` and **Database name** to `microsoftDB`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Microsoft SQL Server Connection global configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-mssql-connection.png) Figure 5. Microsoft SQL Server Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure a MySQL Database Connection Use the **MySQL Connection** field type to connect to a MySQL database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **MySQL Connection**. 5. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `0.0.0.0`, **Port** to `3306`, **User** to `Max`, **Password** to `password`, and **Database** to `someSchema`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The MySQL Connection global configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-mysql-connection.png) Figure 6. MySQL Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure an Oracle Connection Use the **Oracle Connection** field type to connect to an Oracle database. The following example shows how to configure the connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Oracle Connection**. 5. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `192.168.99.100`, **Port** to `1521`, **User** to `system`, **Password** to `oracle`, and **Instance** to `xe`. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect to the database. 10. Click **OK**. The following screenshot shows the configuration in Studio: ![The Oracle Connection global configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-oracle-connection.png) Figure 7. Oracle Connection configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure the JDBC Driver After you configure the connections, add the JDBC driver. The following example shows how to add a driver for the MySQL database: 1. In Studio, add the driver using either of the following options: - In the **Database Config** window, click **Configure**, select **Add Maven dependency**, and pick the dependency: ![Pick Maven dependency](/mulesoft/current/en-us/db-connector/latest/_images/database-dependency.png) Figure 8. Pick Maven dependency - Add the dependency directly to your project’s `pom.xml` file: ```xml mysql mysql-connector-java 5.1.48 ``` 2. Configure your `pom.xml` file so that Mule exposes the driver dependency to Database Connector: ```xml org.mule.tools.maven mule-maven-plugin 1.0.0 mysql mysql-connector-java ``` ## Configure Connection Pools Establishing connections is costly in terms of connectors, the relational database management system (RDBMS) network, and processing overhead. Database Connector supports the use of pooling profiles that enable you to build a connection pool. This is a group of established connections that the connector can use to perform required operations without having to establish new connections every time. When you configure the **Pooling profile** field in the global element of your application, deselect the **Test connection on checkout** field to improve the connector performance with connection pooling. If you leave the field selected as default (`TRUE`), every time a connection is checked out of the pool, the connection pool performs connectivity checks against the database, which increases the time required for each operation to complete. All connection type configurations accept the **Pooling profile** field configuration. In JDBC, pooling occurs at the data source level, so to enable pooling, you have to configure the global data source. The following example shows how to configure a pooling profile for an Oracle database connection with the **Test connection on checkout** field set to `FALSE`: 1. In the **Database Config** window, in the **Advanced** tab, for **Pooling profile** select **Edit inline**. 2. Set the following fields: - **Max pool size**: `30` - **Min pool size**: `4` - **Acquire increment**: `1` - **Prepared statement cache size** `5` - **Max wait**: `0` - **Max wait unit**: `SECONDS (Default)` - **Max idle time** `60` - **Max statements** `0` 3. Deselect **Test connection on checkout**. This sets the field as `FALSE`. 4. For **Column types** select **Edit inline**. 5. Click the (**+**) plus sign to add a column type. 6. In the **Column type** window, set **Id** to `2003`, **Type name** to `1000`, and click **Finish**. 7. Repeat step 5. 8. To add a new column type, set **Id** to `2002`, **Type name** to `PHONE_NUMBER_ARRAY`, and click **Finish**. The following screenshot shows the configuration in Studio: ![The Pooling Profile field Configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-pooling-configuration.png) Figure 9. Pooling Profile Configuration In the XML editor, the `` and `testConnectionOnCheckout="false` configurations look like these: ```xml ``` ## Configure an Oracle Connection with TNS Names The following example shows how to configure the **Generic Connection** field to connect to an Oracle database that relies on the `tnsnames.ora` file. If a firewall separates your Mule runtime engine from the database, use the `ENABLE=BROKEN` parameter to enable a keep-alive connection at the TNS connection. If a keep-alive connection is not set, the connection can drop traffic due to expiring inactivity timers. 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Generic Connection**. 5. Click **Configure** to add the required JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set the connection **URL** to `jdbc:oracle:thin:${oracle.user}/${oracle.password}@(DESCRIPTION=(ENABLE=BROKEN)(FAILOVER=ON)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=${oracle.host1})(PORT=${oracle.port}))(ADDRESS=(PROTOCOL=TCP)(HOST=${oracle.host2})(PORT=${oracle.port})))(CONNECT_DATA=(SERVICE_NAME=${oracle.service})))`. 7. Set **Driver class name** to `oracle.jdbc.driver.OracleDriver`. 8. Click **Test Connection** to validate the connection with the database. 9. Click **OK**. The following screenshot shows the configuration in Studio: ![The Oracle database with TNS configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-oracle-tns.png) Figure 10. Oracle with TNS configuration In the XML editor, the configuration looks like this: ```xml ``` ## Configure Cache Query Template Size The following example shows how to configure the **Cache Query Template Size** field for the connection. 1. In Studio, open the Database Global Configuration window. 2. Select the **Advanced** tab. 3. Set the **Cache Query Template Size** field to your desired value. ![Cache Query Template Size field set to 50](/mulesoft/current/en-us/db-connector/latest/_images/database-cachequery.png) ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure an Oracle TLS Database Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to connect to an Oracle database in a secure way through its dedicated Oracle connection. You can configure the following levels of security for an Oracle connection: - TCPS - connection through secure TCP tunnel (not recommended) - TLS - with Truststore validation only - mTLS - with Truststore and Keystore validations - mTLS - without user and password (role is given by certificates) ## Configure a Secure Oracle Connection The following example shows how to configure a secure Oracle connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Oracle Connection**. 5. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `localhost`, **Port** to `1522`, **User** to `system`, **Password** to `oracle`, and **Instance**/**Service Name** to `xe`. 7. Click **TLS**. 8. In the **Trust Store Configuration** section, set the following fields: - **Path**: `/client-truststore.jks` - **Password**: `somepassword` - **Type**: `JKS` 9. In the **Key Store Configuration** section, set the following fields: - **Path**: `/client-keystore.jks` - **Password**: `somepassword` - **Key Password**: `somepassword` > [!NOTE] Due to Java Secure Socket Extension (JSSE), you must set the **Password** and **Key > Password** fields with the same password value for the Key Store Configuration. - **Type**: `JKS` 10. Click **Test Connection** to confirm that Mule can connect to the database. 11. Click **OK**. The following screenshots show the secure Oracle connection General and TLS configuration windows in Studio: ![Secure Oracle Connection General configuration window](/mulesoft/current/en-us/db-connector/1.14/_images/database-oracle-connection-secure-general.png) In the **Configuration XML** editor, the `tls:context` configuration looks like this: ```xml ``` ## Secure Oracle Connection Levels Examples The following examples show the XML configuration for each secure Oracle connection level: ### TCPS Connection Through Secure TCP Tunnel In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### TLS with Truststore Validation Only In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### mTLS with Truststore and Keystore Validations In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### mTLS without User and Password Note that for this configuration the role is given by certificates. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation) - [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure an Oracle TLS Database Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to connect to an Oracle database in a secure way through its dedicated Oracle connection. You can configure the following levels of security for an Oracle connection: - TCPS - connection through secure TCP tunnel (not recommended) - TLS - with Truststore validation only - mTLS - with Truststore and Keystore validations - mTLS - without user and password (role is given by certificates) ## Configure a Secure Oracle Connection The following example shows how to configure a secure Oracle connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Oracle Connection**. 5. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `localhost`, **Port** to `1522`, **User** to `system`, **Password** to `oracle`, and **Instance**/**Service Name** to `xe`. 7. Click **TLS**. 8. In the **Trust Store Configuration** section, set the following fields: - **Path**: `/client-truststore.jks` - **Password**: `somepassword` - **Type**: `JKS` 9. In the **Key Store Configuration** section, set the following fields: - **Path**: `/client-keystore.jks` - **Password**: `somepassword` - **Key Password**: `somepassword` > [!NOTE] Due to Java Secure Socket Extension (JSSE), you must set the **Password** and **Key > Password** fields with the same password value for the Key Store Configuration. - **Type**: `JKS` 10. Click **Test Connection** to confirm that Mule can connect to the database. 11. Click **OK**. The following screenshots show the secure Oracle connection General and TLS configuration windows in Studio: ![Secure Oracle Connection General configuration window](/mulesoft/current/en-us/db-connector/1.15/_images/database-oracle-connection-secure-general.png) In the **Configuration XML** editor, the `tls:context` configuration looks like this: ```xml ``` ## Secure Oracle Connection Levels Examples The following examples show the XML configuration for each secure Oracle connection level: ### TCPS Connection Through Secure TCP Tunnel In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### TLS with Truststore Validation Only In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### mTLS with Truststore and Keystore Validations In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### mTLS without User and Password Note that for this configuration the role is given by certificates. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation) - [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure an Oracle TLS Database Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to connect to an Oracle database in a secure way through its dedicated Oracle connection. You can configure the following levels of security for an Oracle connection: - TCPS - connection through secure TCP tunnel (not recommended) - TLS - with Truststore validation only - mTLS - with Truststore and Keystore validations - mTLS - without user and password (role is given by certificates) ## Configure a Secure Oracle Connection The following example shows how to configure a secure Oracle connection in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** view. 2. Click **Create** to open the **Choose Global Type** view. 3. In the **Filter** field, type `database`, select **Database Config** and click **OK**. 4. In the **Database Config** window, for the **Connection** field, select **Oracle Connection**. 5. Click **Configure** to add the required Oracle JDBC driver and select either: - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 6. Set **Host** to `localhost`, **Port** to `1522`, **User** to `system`, **Password** to `oracle`, and **Instance**/**Service Name** to `xe`. 7. Click **TLS**. 8. In the **Trust Store Configuration** section, set the following fields: - **Path**: `/client-truststore.jks` - **Password**: `somepassword` - **Type**: `JKS` 9. In the **Key Store Configuration** section, set the following fields: - **Path**: `/client-keystore.jks` - **Password**: `somepassword` - **Key Password**: `somepassword` > [!NOTE] Due to Java Secure Socket Extension (JSSE), you must set the **Password** and **Key > Password** fields with the same password value for the Key Store Configuration. - **Type**: `JKS` 10. Click **Test Connection** to confirm that Mule can connect to the database. 11. Click **OK**. The following screenshots show the secure Oracle connection General and TLS configuration windows in Studio: ![Secure Oracle Connection General configuration window](/mulesoft/current/en-us/db-connector/latest/_images/database-oracle-connection-secure-general.png) In the **Configuration XML** editor, the `tls:context` configuration looks like this: ```xml ``` ## Secure Oracle Connection Levels Examples The following examples show the XML configuration for each secure Oracle connection level: ### TCPS Connection Through Secure TCP Tunnel In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### TLS with Truststore Validation Only In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### mTLS with Truststore and Keystore Validations In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### mTLS without User and Password Note that for this configuration the role is given by certificates. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation) - [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure Azure Active Directory Authentication for MS SQL Server using the Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to configure Azure Active Directory Authentication for MS SQL Server by setting the `IntegratedSecurity` value in the connection configuration. The following example shows how to configure this value in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the filter box, search `database`. 4. Select **Database Config**. 5. Click **OK**. 6. In the **Database Config** window, for **Connection**, select **MS SQL Server Connection**. 7. In the **Advanced** tab, set **Connection properties** to **Edit inline**. 8. Click the green plus sign. 9. Set **Key** to `Integratedsecurity`. 10. Set **Value** to `true`. 11. Click **Finish**. 12. Complete the remaining connection settings for the database. 13. Click **OK**. ![Integratedsecurity key configuration in Anypoint Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-connector-integrated.png) In the **Configuration XML** editor, the `key="integratedsecurity` configuration looks like this: ```xml ``` ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure Azure Active Directory Authentication for MS SQL Server using the Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to configure Azure Active Directory Authentication for MS SQL Server by setting the `IntegratedSecurity` value in the connection configuration. The following example shows how to configure this value in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the filter box, search `database`. 4. Select **Database Config**. 5. Click **OK**. 6. In the **Database Config** window, for **Connection**, select **MS SQL Server Connection**. 7. In the **Advanced** tab, set **Connection properties** to **Edit inline**. 8. Click the green plus sign. 9. Set **Key** to `Integratedsecurity`. 10. Set **Value** to `true`. 11. Click **Finish**. 12. Complete the remaining connection settings for the database. 13. Click **OK**. ![Integratedsecurity key configuration in Anypoint Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-connector-integrated.png) In the **Configuration XML** editor, the `key="integratedsecurity` configuration looks like this: ```xml ``` ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure Azure Active Directory Authentication for MS SQL Server using the Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to configure Azure Active Directory Authentication for MS SQL Server by setting the `IntegratedSecurity` value in the connection configuration. The following example shows how to configure this value in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the filter box, search `database`. 4. Select **Database Config**. 5. Click **OK**. 6. In the **Database Config** window, for **Connection**, select **MS SQL Server Connection**. 7. In the **Advanced** tab, set **Connection properties** to **Edit inline**. 8. Click the green plus sign. 9. Set **Key** to `Integratedsecurity`. 10. Set **Value** to `true`. 11. Click **Finish**. 12. Complete the remaining connection settings for the database. 13. Click **OK**. ![Integratedsecurity key configuration in Anypoint Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-connector-integrated.png) In the **Configuration XML** editor, the `key="integratedsecurity` configuration looks like this: ```xml ``` ## Windows Authentication Limitations on CloudHub and Runtime Fabric Windows Authentication (Integrated Security or NTLM) for MS SQL Server is generally not supported, or is highly impractical, for Mule applications deployed to Linux-based environments such as CloudHub 1.0, CloudHub 2.0, and Runtime Fabric. These environments can’t be joined to a Windows domain. For these environments, use one of these options: - SQL Server authentication (recommended) Connect with a SQL Server login and password. - Kerberos authentication Use this option if your organization requires integrated authentication. See [Kerberos authentication to Microsoft SQL Server from Mule 4 apps hosted in CloudHub or RTF](https://help.salesforce.com/s/articleView?id=001116985&type=1). > [!IMPORTANT] In CloudHub 2.0 and Runtime Fabric, the Microsoft SQL Server JDBC driver attempts > Windows Authentication whenever the user name is in domain format, such as `DOMAIN\user`, even if > `IntegratedSecurity=true` isn’t set. This authentication attempt fails. ## See Also - [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure Database Connector Data Types Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following examples show how to configure Anypoint Connector for Database (Database Connector) data types by using the **Parameters types** field to specify the type of each input parameter in the query and the **Column types** field to set custom data types when connected to a particular database provider. ## Configure the Parameter Types Field in Studio If your JDBC driver either cannot determine the type of the input, or a parameter is of a custom type, configure the **Parameter types** field to specify the type of each input parameter. The following example shows how to configure the **Parameter types** field in the **Bulk insert** operation: 1. In your Studio flow, select the **Bulk insert** operation. 2. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 3. Specify the database connection information and click **OK**. 4. Set the **SQL Query Text** field to the SQL query to execute, for example: `INSERT INTO PLANET(POSITION, NAME) VALUES (:position, :name)` 5. In the operation configuration screen, click the **Advanced** tab. 6. Set the **Parameter types** field to `Edit inline`. 7. Click the green plus sign (**+**) to create a new parameter type. 8. In the parameter type window, set the **Key** field to `name` and the **Type** field to `VARCHAR`. 9. Click **Finish**. 10. Repeat Step 7. 11. In the parameter type window, set the **Key** field to `position` and the **Type** field to `INTEGER`. 12. Click **Finish**. The following screenshot shows the configuration in Studio: ![Set the Parameter types field to Edit Inline and then click the plus sign to create a new parameter](/mulesoft/current/en-us/db-connector/1.14/_images/database-parameter-types.png) Figure 1. Parameter Types field configuration In the XML editor, the `` configuration looks like this: ```xml INSERT INTO PLANET(POSITION, NAME) VALUES (:position, :name) ``` ## Configure the Column Types Field in Studio Each connection provider uses exclusive and common parameters, such as Derby and Oracle. A child element of the connection provider element defines custom data types parameters you can use when connected to a particular provider. The following table provides the JDBC Data Type codes and IDs that you can use to define custom data types:
JDBC Data Type Codeid

ARRAY

2003

BIGINT

-5

BINARY

-2

BIT

-7

BLOB

2004

BOOLEAN

16

CHAR

1

CLOB

2005

DATALINK

70

DATE

91

DECIMAL

3

DISTINCT

2001

DOUBLE

8

FLOAT

6

INTEGER

4

JAVA_OBJECT

2000

LONGNVARCHAR

-16

LONGVARBINARY

-4

LONGVARCHAR

-1

NCHAR

-15

NCLOB

2011

NULL

0

NUMERIC

2

NVARCHAR

-9

OTHER

1111

REAL

7

REF

2006

REF_CURSOR

2012

ROWID

-8

SMALLINT

5

SQLXML

2009

STRUCT

2002

TIME

92

TIME_WITH_TIMEZONE

2013

TIMESTAMP

93

TIMESTAMP_WITH_TIMEZONE

2014

TINYINT

-6

VARBINARY

-3

VARCHAR

12

The following example shows how to configure the **Column types** field in the Derby global configuration connection element: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the **Global Type** window, filter by typing `database`. 4. Select **Database Config** and click **OK**. 5. Set the **Connection** field to `Derby Connection`. 6. Configure the required libraries for the Derby JDBC Driver and the additional connection fields. 7. Click the **Advanced** tab. 8. Set the **Column types** field to `Edit inline`. 9. Click the green plus sign (**+**) to create a custom column type. 10. In the parameter type window, set the **Id** field to `2000` and the **Type** field to `CONTACT_DETAILS`. 11. Click **Finish**. The following screenshot shows the configuration in Studio: ![Set the Column types field to edit inline and then click the plus sign to create a column type](/mulesoft/current/en-us/db-connector/1.14/_images/database-column-types.png) Figure 2. Column Types field configuration In the XML editor, the `` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure Database Connector Data Types Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following examples show how to configure Anypoint Connector for Database (Database Connector) data types by using the **Parameters types** field to specify the type of each input parameter in the query and the **Column types** field to set custom data types when connected to a particular database provider. ## Configure the Parameter Types Field in Studio If your JDBC driver either cannot determine the type of the input, or a parameter is of a custom type, configure the **Parameter types** field to specify the type of each input parameter. The following example shows how to configure the **Parameter types** field in the **Bulk insert** operation: 1. In your Studio flow, select the **Bulk insert** operation. 2. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 3. Specify the database connection information and click **OK**. 4. Set the **SQL Query Text** field to the SQL query to execute, for example: `INSERT INTO PLANET(POSITION, NAME) VALUES (:position, :name)` 5. In the operation configuration screen, click the **Advanced** tab. 6. Set the **Parameter types** field to `Edit inline`. 7. Click the green plus sign (**+**) to create a new parameter type. 8. In the parameter type window, set the **Key** field to `name` and the **Type** field to `VARCHAR`. 9. Click **Finish**. 10. Repeat Step 7. 11. In the parameter type window, set the **Key** field to `position` and the **Type** field to `INTEGER`. 12. Click **Finish**. The following screenshot shows the configuration in Studio: ![Set the Parameter types field to Edit Inline and then click the plus sign to create a new parameter](/mulesoft/current/en-us/db-connector/1.15/_images/database-parameter-types.png) Figure 1. Parameter Types field configuration In the XML editor, the `` configuration looks like this: ```xml INSERT INTO PLANET(POSITION, NAME) VALUES (:position, :name) ``` ## Configure the Column Types Field in Studio Each connection provider uses exclusive and common parameters, such as Derby and Oracle. A child element of the connection provider element defines custom data types parameters you can use when connected to a particular provider. The following table provides the JDBC Data Type codes and IDs that you can use to define custom data types:
JDBC Data Type Codeid

ARRAY

2003

BIGINT

-5

BINARY

-2

BIT

-7

BLOB

2004

BOOLEAN

16

CHAR

1

CLOB

2005

DATALINK

70

DATE

91

DECIMAL

3

DISTINCT

2001

DOUBLE

8

FLOAT

6

INTEGER

4

JAVA_OBJECT

2000

LONGNVARCHAR

-16

LONGVARBINARY

-4

LONGVARCHAR

-1

NCHAR

-15

NCLOB

2011

NULL

0

NUMERIC

2

NVARCHAR

-9

OTHER

1111

REAL

7

REF

2006

REF_CURSOR

2012

ROWID

-8

SMALLINT

5

SQLXML

2009

STRUCT

2002

TIME

92

TIME_WITH_TIMEZONE

2013

TIMESTAMP

93

TIMESTAMP_WITH_TIMEZONE

2014

TINYINT

-6

VARBINARY

-3

VARCHAR

12

The following example shows how to configure the **Column types** field in the Derby global configuration connection element: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the **Global Type** window, filter by typing `database`. 4. Select **Database Config** and click **OK**. 5. Set the **Connection** field to `Derby Connection`. 6. Configure the required libraries for the Derby JDBC Driver and the additional connection fields. 7. Click the **Advanced** tab. 8. Set the **Column types** field to `Edit inline`. 9. Click the green plus sign (**+**) to create a custom column type. 10. In the parameter type window, set the **Id** field to `2000` and the **Type** field to `CONTACT_DETAILS`. 11. Click **Finish**. The following screenshot shows the configuration in Studio: ![Set the Column types field to edit inline and then click the plus sign to create a column type](/mulesoft/current/en-us/db-connector/1.15/_images/database-column-types.png) Figure 2. Column Types field configuration In the XML editor, the `` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure Database Connector Data Types Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following examples show how to configure Anypoint Connector for Database (Database Connector) data types by using the **Parameters types** field to specify the type of each input parameter in the query and the **Column types** field to set custom data types when connected to a particular database provider. ## Configure the Parameter Types Field in Studio If your JDBC driver either cannot determine the type of the input, or a parameter is of a custom type, configure the **Parameter types** field to specify the type of each input parameter. The following example shows how to configure the **Parameter types** field in the **Bulk insert** operation: 1. In your Studio flow, select the **Bulk insert** operation. 2. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 3. Specify the database connection information and click **OK**. 4. Set the **SQL Query Text** field to the SQL query to execute, for example: `INSERT INTO PLANET(POSITION, NAME) VALUES (:position, :name)` 5. In the operation configuration screen, click the **Advanced** tab. 6. Set the **Parameter types** field to `Edit inline`. 7. Click the green plus sign (**+**) to create a new parameter type. 8. In the parameter type window, set the **Key** field to `name` and the **Type** field to `VARCHAR`. 9. Click **Finish**. 10. Repeat Step 7. 11. In the parameter type window, set the **Key** field to `position` and the **Type** field to `INTEGER`. 12. Click **Finish**. The following screenshot shows the configuration in Studio: ![Set the Parameter types field to Edit Inline and then click the plus sign to create a new parameter](/mulesoft/current/en-us/db-connector/latest/_images/database-parameter-types.png) Figure 1. Parameter Types field configuration In the XML editor, the `` configuration looks like this: ```xml INSERT INTO PLANET(POSITION, NAME) VALUES (:position, :name) ``` ## Configure the Column Types Field in Studio Each connection provider uses exclusive and common parameters, such as Derby and Oracle. A child element of the connection provider element defines custom data types parameters you can use when connected to a particular provider. The following table provides the JDBC Data Type codes and IDs that you can use to define custom data types:
JDBC Data Type Codeid

ARRAY

2003

BIGINT

-5

BINARY

-2

BIT

-7

BLOB

2004

BOOLEAN

16

CHAR

1

CLOB

2005

DATALINK

70

DATE

91

DECIMAL

3

DISTINCT

2001

DOUBLE

8

FLOAT

6

INTEGER

4

JAVA_OBJECT

2000

LONGNVARCHAR

-16

LONGVARBINARY

-4

LONGVARCHAR

-1

NCHAR

-15

NCLOB

2011

NULL

0

NUMERIC

2

NVARCHAR

-9

OTHER

1111

REAL

7

REF

2006

REF_CURSOR

2012

ROWID

-8

SMALLINT

5

SQLXML

2009

STRUCT

2002

TIME

92

TIME_WITH_TIMEZONE

2013

TIMESTAMP

93

TIMESTAMP_WITH_TIMEZONE

2014

TINYINT

-6

VARBINARY

-3

VARCHAR

12

The following example shows how to configure the **Column types** field in the Derby global configuration connection element: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the **Global Type** window, filter by typing `database`. 4. Select **Database Config** and click **OK**. 5. Set the **Connection** field to `Derby Connection`. 6. Configure the required libraries for the Derby JDBC Driver and the additional connection fields. 7. Click the **Advanced** tab. 8. Set the **Column types** field to `Edit inline`. 9. Click the green plus sign (**+**) to create a custom column type. 10. In the parameter type window, set the **Id** field to `2000` and the **Type** field to `CONTACT_DETAILS`. 11. Click **Finish**. The following screenshot shows the configuration in Studio: ![Set the Column types field to edit inline and then click the plus sign to create a column type](/mulesoft/current/en-us/db-connector/latest/_images/database-column-types.png) Figure 2. Column Types field configuration In the XML editor, the `` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure Database Transactions Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to execute database operations in the context of a transaction. Each operation has a **Transactional action** field in which you specify the type of joining action that operations can take regarding the active transaction. The following examples illustrate how to configure the **Transactional action** field in Studio, both for the **Select** operation and when grouping operations using the **Try** scope component. ## Configure the Transactional Action Field in Studio To configure the field, follow these steps: 1. In your Studio flow, select the **Select** operation. 2. In the connector configuration screen, click the **Advanced** tab. 3. Set the **Transactional action** field to any of the following options: - **ALWAYS\_JOIN** Expects a transaction to be in progress when a message is received. If there is no transaction, an error is raised. - **JOIN\_IF\_POSSIBLE** Joins the current transaction if one is available. Otherwise, no transaction occurs. - **NOT\_SUPPORTED** Executes outside any existing transaction. The following screenshot shows the configuration in Studio: ![The Transactional action field configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-transactions-1.png) Figure 1. Transactional action configuration In the XML editor, the `transactionalAction` configuration looks like this: ```xml ``` ## Configure the Transactional Action Field in the Try Scope to Group Operations Sometimes you need to execute several queries atomically in the context of the same transaction. If these queries are executed in the context of an already-existing transaction, the queries belong to the same transaction. The following example shows that during a bank account transfer, you use two Database Connector **Update** operations to subtract money from one account and add it to another, but if any of the two operations fails, roll back both. If there’s no active transaction, you can start one by grouping the operations using the **Try** scope component: 1. In the **Mule Palette** view, search for `try` and select the **Try** scope component. 2. Drag the **Try** scope component onto the Studio canvas. 3. Drag an **Update** operation inside the **Try** scope component. 4. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 5. Specify the database connection information and click **OK**. 6. Set the **SQL Query Text** field to the SQL query to execute, for example, `UPDATE ACCOUNT set BALANCE = BALANCE - :money where ID = :source`. 7. Set the **Input Parameters** field to `{‘money’ : payload.money, ‘source’: payload.source}`. 8. Drag another **Update** operation to the right of the first **Update** operation inside the **Try** component. 9. Set the **Connector configuration** field to the previously created database connection. 10. Set the **SQL Query Text** field to the SQL query to execute, for example, `UPDATE ACCOUNT set BALANCE = BALANCE + :money where ID = :target`. 11. Set the **Input Parameters** field to `{‘money’ : payload.money, ‘target’’: payload.target}`. 12. Select the **Try** scope component in your flow. 13. In the component configuration screen, set the **Transactional action** field to `ALWAYS_BEGIN`. The following screenshot shows the configuration in Studio: ![The Transactional action field configuration for the Try component in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-transactions-2.png) Figure 2. Transactional action configuration In the XML editor, the `transactionalAction` configuration looks like this: ```xml UPDATE ACCOUNT set BALANCE = BALANCE - :money where ID = :source #[{'money' : payload.money, 'source': payload.source}] UPDATE ACCOUNT set BALANCE = BALANCE + :money where ID = :target #[{'money' : payload.money, 'target'': payload.target}] ``` ## Transactions and Streaming Results from some Database Connector operations (for example the **Select** operation) are automatically streamed to prevent loading all the results at once, which can lead to performance and memory issues. This behavior means that database rows are loaded lazily when needed. When Database Connector operations are performed inside a transaction (for example a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded will fail. ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure Database Transactions Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to execute database operations in the context of a transaction. Each operation has a **Transactional action** field in which you specify the type of joining action that operations can take regarding the active transaction. The following examples illustrate how to configure the **Transactional action** field in Studio, both for the **Select** operation and when grouping operations using the **Try** scope component. ## Configure the Transactional Action Field in Studio To configure the field, follow these steps: 1. In your Studio flow, select the **Select** operation. 2. In the connector configuration screen, click the **Advanced** tab. 3. Set the **Transactional action** field to any of the following options: - **ALWAYS\_JOIN** Expects a transaction to be in progress when a message is received. If there is no transaction, an error is raised. - **JOIN\_IF\_POSSIBLE** Joins the current transaction if one is available. Otherwise, no transaction occurs. - **NOT\_SUPPORTED** Executes outside any existing transaction. The following screenshot shows the configuration in Studio: ![The Transactional action field configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-transactions-1.png) Figure 1. Transactional action configuration In the XML editor, the `transactionalAction` configuration looks like this: ```xml ``` ## Configure the Transactional Action Field in the Try Scope to Group Operations Sometimes you need to execute several queries atomically in the context of the same transaction. If these queries are executed in the context of an already-existing transaction, the queries belong to the same transaction. The following example shows that during a bank account transfer, you use two Database Connector **Update** operations to subtract money from one account and add it to another, but if any of the two operations fails, roll back both. If there’s no active transaction, you can start one by grouping the operations using the **Try** scope component: 1. In the **Mule Palette** view, search for `try` and select the **Try** scope component. 2. Drag the **Try** scope component onto the Studio canvas. 3. Drag an **Update** operation inside the **Try** scope component. 4. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 5. Specify the database connection information and click **OK**. 6. Set the **SQL Query Text** field to the SQL query to execute, for example, `UPDATE ACCOUNT set BALANCE = BALANCE - :money where ID = :source`. 7. Set the **Input Parameters** field to `{‘money’ : payload.money, ‘source’: payload.source}`. 8. Drag another **Update** operation to the right of the first **Update** operation inside the **Try** component. 9. Set the **Connector configuration** field to the previously created database connection. 10. Set the **SQL Query Text** field to the SQL query to execute, for example, `UPDATE ACCOUNT set BALANCE = BALANCE + :money where ID = :target`. 11. Set the **Input Parameters** field to `{‘money’ : payload.money, ‘target’’: payload.target}`. 12. Select the **Try** scope component in your flow. 13. In the component configuration screen, set the **Transactional action** field to `ALWAYS_BEGIN`. The following screenshot shows the configuration in Studio: ![The Transactional action field configuration for the Try component in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-transactions-2.png) Figure 2. Transactional action configuration In the XML editor, the `transactionalAction` configuration looks like this: ```xml UPDATE ACCOUNT set BALANCE = BALANCE - :money where ID = :source #[{'money' : payload.money, 'source': payload.source}] UPDATE ACCOUNT set BALANCE = BALANCE + :money where ID = :target #[{'money' : payload.money, 'target'': payload.target}] ``` ## Transactions and Streaming Results from some Database Connector operations (for example the **Select** operation) are automatically streamed to prevent loading all the results at once, which can lead to performance and memory issues. This behavior means that database rows are loaded lazily when needed. When Database Connector operations are performed inside a transaction (for example a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded will fail. ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure Database Transactions Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to execute database operations in the context of a transaction. Each operation has a **Transactional action** field in which you specify the type of joining action that operations can take regarding the active transaction. The following examples illustrate how to configure the **Transactional action** field in Studio, both for the **Select** operation and when grouping operations using the **Try** scope component. ## Configure the Transactional Action Field in Studio To configure the field, follow these steps: 1. In your Studio flow, select the **Select** operation. 2. In the connector configuration screen, click the **Advanced** tab. 3. Set the **Transactional action** field to any of the following options: - **ALWAYS\_JOIN** Expects a transaction to be in progress when a message is received. If there is no transaction, an error is raised. - **JOIN\_IF\_POSSIBLE** Joins the current transaction if one is available. Otherwise, no transaction occurs. - **NOT\_SUPPORTED** Executes outside any existing transaction. The following screenshot shows the configuration in Studio: ![The Transactional action field configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-transactions-1.png) Figure 1. Transactional action configuration In the XML editor, the `transactionalAction` configuration looks like this: ```xml ``` ## Configure the Transactional Action Field in the Try Scope to Group Operations Sometimes you need to execute several queries atomically in the context of the same transaction. If these queries are executed in the context of an already-existing transaction, the queries belong to the same transaction. The following example shows that during a bank account transfer, you use two Database Connector **Update** operations to subtract money from one account and add it to another, but if any of the two operations fails, roll back both. If there’s no active transaction, you can start one by grouping the operations using the **Try** scope component: 1. In the **Mule Palette** view, search for `try` and select the **Try** scope component. 2. Drag the **Try** scope component onto the Studio canvas. 3. Drag an **Update** operation inside the **Try** scope component. 4. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 5. Specify the database connection information and click **OK**. 6. Set the **SQL Query Text** field to the SQL query to execute, for example, `UPDATE ACCOUNT set BALANCE = BALANCE - :money where ID = :source`. 7. Set the **Input Parameters** field to `{‘money’ : payload.money, ‘source’: payload.source}`. 8. Drag another **Update** operation to the right of the first **Update** operation inside the **Try** component. 9. Set the **Connector configuration** field to the previously created database connection. 10. Set the **SQL Query Text** field to the SQL query to execute, for example, `UPDATE ACCOUNT set BALANCE = BALANCE + :money where ID = :target`. 11. Set the **Input Parameters** field to `{‘money’ : payload.money, ‘target’’: payload.target}`. 12. Select the **Try** scope component in your flow. 13. In the component configuration screen, set the **Transactional action** field to `ALWAYS_BEGIN`. The following screenshot shows the configuration in Studio: ![The Transactional action field configuration for the Try component in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-transactions-2.png) Figure 2. Transactional action configuration In the XML editor, the `transactionalAction` configuration looks like this: ```xml UPDATE ACCOUNT set BALANCE = BALANCE - :money where ID = :source #[{'money' : payload.money, 'source': payload.source}] UPDATE ACCOUNT set BALANCE = BALANCE + :money where ID = :target #[{'money' : payload.money, 'target'': payload.target}] ``` ## Transactions and Streaming Results from some Database Connector operations (for example the **Select** operation) are automatically streamed to prevent loading all the results at once, which can lead to performance and memory issues. This behavior means that database rows are loaded lazily when needed. When Database Connector operations are performed inside a transaction (for example a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded will fail. ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure Driver Visibility using Mule Maven Plugin > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although Anypoint Studio enables you to configure database driver dependencies without problems in most cases, there are some scenarios where you must use the Mule Maven Plugin to properly set up the driver classes' visibility because of class loading isolation mechanisms. ## Configure Driver Visibility Across the Application To configure additional database driver dependencies and make the driver visible across components within your Mule application, refer to the [Configure Shared Libraries](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept#configure-shared-libraries) section in the Mule Maven Plugin documentation. ## Configure Driver Visibility Only for the Connector When there is a risk of dependencies colliding and it’s necessary to have the Database Connector and the driver’s dependencies in the same class loader, to make the driver visible only for the connector, refer to the [Configure Additional Plugin Dependencies](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept#configure-plugin-dependencies) section in the Mule Maven Plugin documentation. > [!NOTE] Be aware of which component must establish the connection with the database, as the driver > must be in the scope of that component’s class loader. For example, if a Mule application uses a > datasource reference connection and targets a Spring bean datasource definition, it is the > Spring’s class loader that requires the database library, not the database. Configure additional > application dependencies using _shared libraries_. ## See Also - [Mule Maven Plugin](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure Driver Visibility using Mule Maven Plugin > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although Anypoint Studio enables you to configure database driver dependencies without problems in most cases, there are some scenarios where you must use the Mule Maven Plugin to properly set up the driver classes' visibility because of class loading isolation mechanisms. ## Configure Driver Visibility Across the Application To configure additional database driver dependencies and make the driver visible across components within your Mule application, refer to the [Configure Shared Libraries](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept#configure-shared-libraries) section in the Mule Maven Plugin documentation. ## Configure Driver Visibility Only for the Connector When there is a risk of dependencies colliding and it’s necessary to have the Database Connector and the driver’s dependencies in the same class loader, to make the driver visible only for the connector, refer to the [Configure Additional Plugin Dependencies](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept#configure-plugin-dependencies) section in the Mule Maven Plugin documentation. > [!NOTE] Be aware of which component must establish the connection with the database, as the driver > must be in the scope of that component’s class loader. For example, if a Mule application uses a > datasource reference connection and targets a Spring bean datasource definition, it is the > Spring’s class loader that requires the database library, not the database. Configure additional > application dependencies using _shared libraries_. ## See Also - [Mule Maven Plugin](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure Driver Visibility using Mule Maven Plugin > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although Anypoint Studio enables you to configure database driver dependencies without problems in most cases, there are some scenarios where you must use the Mule Maven Plugin to properly set up the driver classes' visibility because of class loading isolation mechanisms. ## Configure Driver Visibility Across the Application To configure additional database driver dependencies and make the driver visible across components within your Mule application, refer to the [Configure Shared Libraries](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept#configure-shared-libraries) section in the Mule Maven Plugin documentation. ## Configure Driver Visibility Only for the Connector When there is a risk of dependencies colliding and it’s necessary to have the Database Connector and the driver’s dependencies in the same class loader, to make the driver visible only for the connector, refer to the [Configure Additional Plugin Dependencies](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept#configure-plugin-dependencies) section in the Mule Maven Plugin documentation. > [!NOTE] Be aware of which component must establish the connection with the database, as the driver > must be in the scope of that component’s class loader. For example, if a Mule application uses a > datasource reference connection and targets a Spring bean datasource definition, it is the > Spring’s class loader that requires the database library, not the database. Configure additional > application dependencies using _shared libraries_. ## See Also - [Mule Maven Plugin](https://docs.mulesoft.com/mule-runtime/latest/mmp-concept) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configure Use Bulk Copy for Database Connector SQL Server Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt You can configure the bulk copy for batch insert in Anypoint Connector for Database (Database Connector) for the Microsoft SQL Server Connection. This feature allows you to enable the driver to do bulk copy operations when executing batch insert operations. Configure this feature as a connection property in the Database Connector Configuration screen. 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the search bar, type `database`. 4. Select **Database config**. 5. Click **OK**. 6. In the **Global Elements Properties** screen, set **Connection** to **Microsoft SQL Server Connection**. 7. Click the **Advanced** tab. 8. Set **Connection properties** to **Edit inline**. 9. Click the plus sign to add a new property. 10. In the **Connection property** screen, set **Key** to `useBulkCopyForBatchInsert`. 11. Set **Value** to `true`. ![useBulkCopyforBatchInsert property created under the Connection property section](/mulesoft/current/en-us/db-connector/1.14/_images/database-bulkcopy.png) ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Configure Use Bulk Copy for Database Connector SQL Server Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt You can configure the bulk copy for batch insert in Anypoint Connector for Database (Database Connector) for the Microsoft SQL Server Connection. This feature allows you to enable the driver to do bulk copy operations when executing batch insert operations. Configure this feature as a connection property in the Database Connector Configuration screen. 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the search bar, type `database`. 4. Select **Database config**. 5. Click **OK**. 6. In the **Global Elements Properties** screen, set **Connection** to **Microsoft SQL Server Connection**. 7. Click the **Advanced** tab. 8. Set **Connection properties** to **Edit inline**. 9. Click the plus sign to add a new property. 10. In the **Connection property** screen, set **Key** to `useBulkCopyForBatchInsert`. 11. Set **Value** to `true`. ![useBulkCopyforBatchInsert property created under the Connection property section](/mulesoft/current/en-us/db-connector/1.15/_images/database-bulkcopy.png) ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Configure Use Bulk Copy for Database Connector SQL Server Connection > For the full documentation index, see: https://docs.mulesoft.com/llms.txt You can configure the bulk copy for batch insert in Anypoint Connector for Database (Database Connector) for the Microsoft SQL Server Connection. This feature allows you to enable the driver to do bulk copy operations when executing batch insert operations. Configure this feature as a connection property in the Database Connector Configuration screen. 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the search bar, type `database`. 4. Select **Database config**. 5. Click **OK**. 6. In the **Global Elements Properties** screen, set **Connection** to **Microsoft SQL Server Connection**. 7. Click the **Advanced** tab. 8. Set **Connection properties** to **Edit inline**. 9. Click the plus sign to add a new property. 10. In the **Connection property** screen, set **Key** to `useBulkCopyForBatchInsert`. 11. Set **Value** to `true`. ![useBulkCopyforBatchInsert property created under the Connection property section](/mulesoft/current/en-us/db-connector/latest/_images/database-bulkcopy.png) ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Configuring Input and Output Parameters for Stored Procedures > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Configure input or output parameters for the **Stored procedure** operation of Anypoint Connector for Database (Database Connector) to specify the parameters that a stored procedure uses. There are input parameters (values passed into the procedure), output parameters (values returned by the procedure), or in out parameters, which are a combination of both. In Anypoint Studio, you can configure the parameters for the **Stored procedure** operation by using the following fields: - **Input parameters** Parameters for which values are provided as inputs to the stored procedure. You typically pass values from your Mule app to the stored procedure through these parameters. - **Output parameters** Parameters used to return values from the stored procedure back to your Mule app. After executing the stored procedure, you can retrieve the values assigned to these parameters. - **In out parameters** Parameters that act as both input and output parameters. You can pass a value into the stored procedure through these parameters. ## Configure Input Parameters Consider a scenario in which you develop a Mule app to manage customer orders. In this case, you retrieve order information from a database by using a stored procedure that takes parameters such as the customer ID and order status. The following example illustrates how to configure the **Input parameters** field of the **Stored procedure** operation to dynamically fetch order details based on specific criteria: 1. In Studio, add a **Database Configuration** element to your Mule app project and configure it with the necessary MySQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call GetOrderDetails(:customerId, :orderStatus)}`. This defines the SQL statement for calling the stored procedure `GetOrderDetails` with the named parameters `customerId` and `orderStatus`. 5. In the **Input parameters** field, enter the following expression to fetch the order details: ```xml { "name": "customerId", "type": "INTEGER", "value": #[flowVars.customerId] }, { "name": "orderStatus", "type": "VARCHAR", "value": #[message.inboundProperties['orderStatus']] } ``` - `name` Name of the input parameter. - `type` Data type of the input parameter. - `value` Value of the input parameter, specified using Mule expression syntax. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure Output Parameters Consider a scenario in which you develop a Mule app for an online retail system. The Mule app manages order processing, and you want to use a stored procedure to implement a feature that retrieves order details and calculates the total amount of an order from a MySQL database. In this scenario, the stored procedure returns details such as the order items, order quantities, and the total amount as an output parameter. The following example demonstrates how to configure the **Output parameters** field of the **Stored procedure** operation to fetch order details and the total amount dynamically. 1. In Studio, add a **Database Configuration** element to your MuleSoft app project and configure it with the necessary MySQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call GetOrderDetails(:orderId, :totalAmount, :orderDetails)}`. This defines the SQL statement for calling the stored procedure `GetOrderDetails` and retrieving output parameters such as `orderId`, `totalAmount`, and `orderDetails`. 5. Set **Output parameters** to **Edit inline**. 6. Click the plus icon to open the &Output parameter\* window. 7. In the **Output parameter** window, set the following parameters:
KeyType Value

orderId

INTEGER

totalAmount

Decimal

orderDetails

ARRAY

8. Click **Finish**. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure In Out Parameters Consider a scenario in which you develop a Mule app for an inventory management system to handle the process of updating the stock levels for specific products. In this scenario, the Mule app interacts with a stored procedure named `UpdateStockLevel` in a PostgreSQL database, which requires both input and output parameters. This following example illustrates how to configure the **In out parameters** field of the **Stored procedure** operation to manage the stock level updates, including both the input data (product ID and quantity) and the output data (updated stock level). 1. In Studio, add a **Database Configuration** element to your MuleSoft app project and configure it with the necessary PostgreSQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call UpdateStockLevel(:productId, :quantity, :updatedStockLevel)}`. This creates an SQL statement that calls a stored procedure named `UpdateStockLevel` with the `productId` and `quantity` input parameters and the\`updatedStockLevel\` output parameter. 5. Set **In out parameters** to **Edit inline**. 6. Click the plus icon to open the **In out parameter** window. 7. In the **In out parameter** window, assign values to the following parameters:
KeyValue

productId

#[payload.productId]

quantity

#[payload.quantity]

updatedStockLevel

(empty)

8. Click **Finish**. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure Custom Types The ability to use custom types as parameters in stored procedures depends on the database system you are using and the capabilities of the Database Connector or framework you are working with. Exercise caution when you work with an Oracle database vendor by using the **Stored procedure** operation with custom database types. \+ When you define the stored procedure within a package, set the column type of a custom type parameter in the connector connection settings: 1. In Studio, open the **Database Config Global Element Properties** window. 2. Click the **Advanced** tab. 3. Set **Column types** to **Edit inline**. 4. Click the plus sign to open the **Column types** window. 5. In the **Column types** window, set the **Id** and **Type name** fields with your desired values. 6. Click **OK**. ![Column type configuration window](/mulesoft/current/en-us/db-connector/1.14/_images/database-column-type.png) In the **Configuration XML** editor window, the configuration looks like this: ```xml ``` It is a good practice to define the **Column types** of a custom type parameter, even if the stored procedure is not part of a package. ## Configuration Considerations Review the following considerations when you configure **In out parameters**. ### Variable Values in Stored Procedures The following consideration applies to all database vendors. In Mule runtime engine (Mule), if you pass a variable with a given set of values to a stored procedure as **In out parameters**, the variable cannot contain modified values after the operation completes. The modified values are part of the operation’s payload, instead. To illustrate this behavior, consider the following scenario: A parameter registered as **In out parameters** has a value stored in a variable named `foo`. If `vars.foo` is passed to the stored procedure, `vars.foo`, it retains its original value after the operation is invoked. When you chain stored procedures, you might expect that when you call stored procedure `A`, the value of `vars.foo` would change, allowing you to subsequently call stored procedure `B` with the already modified values. However, the modified data is returned as an entry in the payload after the operation executes. The payload contains modified values that the stored procedure can create. Consequently, chaining stored procedures is feasible by invoking only one stored procedure per operation. Use the [`prepareArray` and `prepareStruct` functions](https://docs.mulesoft.com/db-connector/1.14/database-connector-udt-stored-procedure#using-preparestruct-and-preparearray-functions) to properly format the data for the **Stored procedure** operation. ### Data Format for Returned Data A **Stored procedure** operation returns data in a format that differs from what it expects. The limitation applies to all database vendors. To illustrate this behavior, consider the following scenario: The **Stored procedure** operation expects an SQL array or SQL struct on the input, which is correctly resolved by using the `prepareArray` and `prepareStruct` functions. However, when Mule performs the operation, a Java object containing the modified values is returned. As a result, the operation returns data in a different format than the expected one, which can become an issue when chaining stored procedures. Use the [`prepareArray` and `prepareStruct` functions](https://docs.mulesoft.com/db-connector/1.14/database-connector-udt-stored-procedure#using-preparestruct-and-preparearray-functions) to properly format the data for the **Stored procedure** operation. --- product: Database Connector version: 1.15 --- # Configuring Input and Output Parameters for Stored Procedures > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Configure input or output parameters for the **Stored procedure** operation of Anypoint Connector for Database (Database Connector) to specify the parameters that a stored procedure uses. There are input parameters (values passed into the procedure), output parameters (values returned by the procedure), or in out parameters, which are a combination of both. In Anypoint Studio, you can configure the parameters for the **Stored procedure** operation by using the following fields: - **Input parameters** Parameters for which values are provided as inputs to the stored procedure. You typically pass values from your Mule app to the stored procedure through these parameters. - **Output parameters** Parameters used to return values from the stored procedure back to your Mule app. After executing the stored procedure, you can retrieve the values assigned to these parameters. - **In out parameters** Parameters that act as both input and output parameters. You can pass a value into the stored procedure through these parameters. ## Configure Input Parameters Consider a scenario in which you develop a Mule app to manage customer orders. In this case, you retrieve order information from a database by using a stored procedure that takes parameters such as the customer ID and order status. The following example illustrates how to configure the **Input parameters** field of the **Stored procedure** operation to dynamically fetch order details based on specific criteria: 1. In Studio, add a **Database Configuration** element to your Mule app project and configure it with the necessary MySQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call GetOrderDetails(:customerId, :orderStatus)}`. This defines the SQL statement for calling the stored procedure `GetOrderDetails` with the named parameters `customerId` and `orderStatus`. 5. In the **Input parameters** field, enter the following expression to fetch the order details: ```xml { "name": "customerId", "type": "INTEGER", "value": #[flowVars.customerId] }, { "name": "orderStatus", "type": "VARCHAR", "value": #[message.inboundProperties['orderStatus']] } ``` - `name` Name of the input parameter. - `type` Data type of the input parameter. - `value` Value of the input parameter, specified using Mule expression syntax. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure Output Parameters Consider a scenario in which you develop a Mule app for an online retail system. The Mule app manages order processing, and you want to use a stored procedure to implement a feature that retrieves order details and calculates the total amount of an order from a MySQL database. In this scenario, the stored procedure returns details such as the order items, order quantities, and the total amount as an output parameter. The following example demonstrates how to configure the **Output parameters** field of the **Stored procedure** operation to fetch order details and the total amount dynamically. 1. In Studio, add a **Database Configuration** element to your MuleSoft app project and configure it with the necessary MySQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call GetOrderDetails(:orderId, :totalAmount, :orderDetails)}`. This defines the SQL statement for calling the stored procedure `GetOrderDetails` and retrieving output parameters such as `orderId`, `totalAmount`, and `orderDetails`. 5. Set **Output parameters** to **Edit inline**. 6. Click the plus icon to open the &Output parameter\* window. 7. In the **Output parameter** window, set the following parameters:
KeyType Value

orderId

INTEGER

totalAmount

Decimal

orderDetails

ARRAY

8. Click **Finish**. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure In Out Parameters Consider a scenario in which you develop a Mule app for an inventory management system to handle the process of updating the stock levels for specific products. In this scenario, the Mule app interacts with a stored procedure named `UpdateStockLevel` in a PostgreSQL database, which requires both input and output parameters. This following example illustrates how to configure the **In out parameters** field of the **Stored procedure** operation to manage the stock level updates, including both the input data (product ID and quantity) and the output data (updated stock level). 1. In Studio, add a **Database Configuration** element to your MuleSoft app project and configure it with the necessary PostgreSQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call UpdateStockLevel(:productId, :quantity, :updatedStockLevel)}`. This creates an SQL statement that calls a stored procedure named `UpdateStockLevel` with the `productId` and `quantity` input parameters and the\`updatedStockLevel\` output parameter. 5. Set **In out parameters** to **Edit inline**. 6. Click the plus icon to open the **In out parameter** window. 7. In the **In out parameter** window, assign values to the following parameters:
KeyValue

productId

#[payload.productId]

quantity

#[payload.quantity]

updatedStockLevel

(empty)

8. Click **Finish**. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure Custom Types The ability to use custom types as parameters in stored procedures depends on the database system you are using and the capabilities of the Database Connector or framework you are working with. Exercise caution when you work with an Oracle database vendor by using the **Stored procedure** operation with custom database types. \+ When you define the stored procedure within a package, set the column type of a custom type parameter in the connector connection settings: 1. In Studio, open the **Database Config Global Element Properties** window. 2. Click the **Advanced** tab. 3. Set **Column types** to **Edit inline**. 4. Click the plus sign to open the **Column types** window. 5. In the **Column types** window, set the **Id** and **Type name** fields with your desired values. 6. Click **OK**. ![Column type configuration window](/mulesoft/current/en-us/db-connector/1.15/_images/database-column-type.png) In the **Configuration XML** editor window, the configuration looks like this: ```xml ``` It is a good practice to define the **Column types** of a custom type parameter, even if the stored procedure is not part of a package. ## Configuration Considerations Review the following considerations when you configure **In out parameters**. ### Variable Values in Stored Procedures The following consideration applies to all database vendors. In Mule runtime engine (Mule), if you pass a variable with a given set of values to a stored procedure as **In out parameters**, the variable cannot contain modified values after the operation completes. The modified values are part of the operation’s payload, instead. To illustrate this behavior, consider the following scenario: A parameter registered as **In out parameters** has a value stored in a variable named `foo`. If `vars.foo` is passed to the stored procedure, `vars.foo`, it retains its original value after the operation is invoked. When you chain stored procedures, you might expect that when you call stored procedure `A`, the value of `vars.foo` would change, allowing you to subsequently call stored procedure `B` with the already modified values. However, the modified data is returned as an entry in the payload after the operation executes. The payload contains modified values that the stored procedure can create. Consequently, chaining stored procedures is feasible by invoking only one stored procedure per operation. Use the [`prepareArray` and `prepareStruct` functions](https://docs.mulesoft.com/db-connector/1.15/database-connector-udt-stored-procedure#using-preparestruct-and-preparearray-functions) to properly format the data for the **Stored procedure** operation. ### Data Format for Returned Data A **Stored procedure** operation returns data in a format that differs from what it expects. The limitation applies to all database vendors. To illustrate this behavior, consider the following scenario: The **Stored procedure** operation expects an SQL array or SQL struct on the input, which is correctly resolved by using the `prepareArray` and `prepareStruct` functions. However, when Mule performs the operation, a Java object containing the modified values is returned. As a result, the operation returns data in a different format than the expected one, which can become an issue when chaining stored procedures. Use the [`prepareArray` and `prepareStruct` functions](https://docs.mulesoft.com/db-connector/1.15/database-connector-udt-stored-procedure#using-preparestruct-and-preparearray-functions) to properly format the data for the **Stored procedure** operation. --- product: Database Connector version: 1.16 is-latest-version: true --- # Configuring Input and Output Parameters for Stored Procedures > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Configure input or output parameters for the **Stored procedure** operation of Anypoint Connector for Database (Database Connector) to specify the parameters that a stored procedure uses. There are input parameters (values passed into the procedure), output parameters (values returned by the procedure), or in out parameters, which are a combination of both. In Anypoint Studio, you can configure the parameters for the **Stored procedure** operation by using the following fields: - **Input parameters** Parameters for which values are provided as inputs to the stored procedure. You typically pass values from your Mule app to the stored procedure through these parameters. - **Output parameters** Parameters used to return values from the stored procedure back to your Mule app. After executing the stored procedure, you can retrieve the values assigned to these parameters. - **In out parameters** Parameters that act as both input and output parameters. You can pass a value into the stored procedure through these parameters. ## Configure Input Parameters Consider a scenario in which you develop a Mule app to manage customer orders. In this case, you retrieve order information from a database by using a stored procedure that takes parameters such as the customer ID and order status. The following example illustrates how to configure the **Input parameters** field of the **Stored procedure** operation to dynamically fetch order details based on specific criteria: 1. In Studio, add a **Database Configuration** element to your Mule app project and configure it with the necessary MySQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call GetOrderDetails(:customerId, :orderStatus)}`. This defines the SQL statement for calling the stored procedure `GetOrderDetails` with the named parameters `customerId` and `orderStatus`. 5. In the **Input parameters** field, enter the following expression to fetch the order details: ```xml { "name": "customerId", "type": "INTEGER", "value": #[flowVars.customerId] }, { "name": "orderStatus", "type": "VARCHAR", "value": #[message.inboundProperties['orderStatus']] } ``` - `name` Name of the input parameter. - `type` Data type of the input parameter. - `value` Value of the input parameter, specified using Mule expression syntax. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure Output Parameters Consider a scenario in which you develop a Mule app for an online retail system. The Mule app manages order processing, and you want to use a stored procedure to implement a feature that retrieves order details and calculates the total amount of an order from a MySQL database. In this scenario, the stored procedure returns details such as the order items, order quantities, and the total amount as an output parameter. The following example demonstrates how to configure the **Output parameters** field of the **Stored procedure** operation to fetch order details and the total amount dynamically. 1. In Studio, add a **Database Configuration** element to your MuleSoft app project and configure it with the necessary MySQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call GetOrderDetails(:orderId, :totalAmount, :orderDetails)}`. This defines the SQL statement for calling the stored procedure `GetOrderDetails` and retrieving output parameters such as `orderId`, `totalAmount`, and `orderDetails`. 5. Set **Output parameters** to **Edit inline**. 6. Click the plus icon to open the &Output parameter\* window. 7. In the **Output parameter** window, set the following parameters:
KeyType Value

orderId

INTEGER

totalAmount

Decimal

orderDetails

ARRAY

8. Click **Finish**. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure In Out Parameters Consider a scenario in which you develop a Mule app for an inventory management system to handle the process of updating the stock levels for specific products. In this scenario, the Mule app interacts with a stored procedure named `UpdateStockLevel` in a PostgreSQL database, which requires both input and output parameters. This following example illustrates how to configure the **In out parameters** field of the **Stored procedure** operation to manage the stock level updates, including both the input data (product ID and quantity) and the output data (updated stock level). 1. In Studio, add a **Database Configuration** element to your MuleSoft app project and configure it with the necessary PostgreSQL database connection details. 2. Drag the **Stored procedure** operation to your canvas to retrieve the order information. 3. Select the operation from your flow. 4. In the **SQL Query text** field, enter `{call UpdateStockLevel(:productId, :quantity, :updatedStockLevel)}`. This creates an SQL statement that calls a stored procedure named `UpdateStockLevel` with the `productId` and `quantity` input parameters and the\`updatedStockLevel\` output parameter. 5. Set **In out parameters** to **Edit inline**. 6. Click the plus icon to open the **In out parameter** window. 7. In the **In out parameter** window, assign values to the following parameters:
KeyValue

productId

#[payload.productId]

quantity

#[payload.quantity]

updatedStockLevel

(empty)

8. Click **Finish**. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Configure Custom Types The ability to use custom types as parameters in stored procedures depends on the database system you are using and the capabilities of the Database Connector or framework you are working with. Exercise caution when you work with an Oracle database vendor by using the **Stored procedure** operation with custom database types. \+ When you define the stored procedure within a package, set the column type of a custom type parameter in the connector connection settings: 1. In Studio, open the **Database Config Global Element Properties** window. 2. Click the **Advanced** tab. 3. Set **Column types** to **Edit inline**. 4. Click the plus sign to open the **Column types** window. 5. In the **Column types** window, set the **Id** and **Type name** fields with your desired values. 6. Click **OK**. ![Column type configuration window](/mulesoft/current/en-us/db-connector/latest/_images/database-column-type.png) In the **Configuration XML** editor window, the configuration looks like this: ```xml ``` It is a good practice to define the **Column types** of a custom type parameter, even if the stored procedure is not part of a package. ## Configuration Considerations Review the following considerations when you configure **In out parameters**. ### Variable Values in Stored Procedures The following consideration applies to all database vendors. In Mule runtime engine (Mule), if you pass a variable with a given set of values to a stored procedure as **In out parameters**, the variable cannot contain modified values after the operation completes. The modified values are part of the operation’s payload, instead. To illustrate this behavior, consider the following scenario: A parameter registered as **In out parameters** has a value stored in a variable named `foo`. If `vars.foo` is passed to the stored procedure, `vars.foo`, it retains its original value after the operation is invoked. When you chain stored procedures, you might expect that when you call stored procedure `A`, the value of `vars.foo` would change, allowing you to subsequently call stored procedure `B` with the already modified values. However, the modified data is returned as an entry in the payload after the operation executes. The payload contains modified values that the stored procedure can create. Consequently, chaining stored procedures is feasible by invoking only one stored procedure per operation. Use the [`prepareArray` and `prepareStruct` functions](https://docs.mulesoft.com/db-connector/latest/database-connector-udt-stored-procedure#using-preparestruct-and-preparearray-functions) to properly format the data for the **Stored procedure** operation. ### Data Format for Returned Data A **Stored procedure** operation returns data in a format that differs from what it expects. The limitation applies to all database vendors. To illustrate this behavior, consider the following scenario: The **Stored procedure** operation expects an SQL array or SQL struct on the input, which is correctly resolved by using the `prepareArray` and `prepareStruct` functions. However, when Mule performs the operation, a Java object containing the modified values is returned. As a result, the operation returns data in a different format than the expected one, which can become an issue when chaining stored procedures. Use the [`prepareArray` and `prepareStruct` functions](https://docs.mulesoft.com/db-connector/latest/database-connector-udt-stored-procedure#using-preparestruct-and-preparearray-functions) to properly format the data for the **Stored procedure** operation. --- product: Database Connector version: 1.14 --- # Database Connector 1.14 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) establishes communication between your Mule app and a relational database. Database Connector can connect to almost any Java Database Connectivity (JDBC) relational database and run SQL operations. An application can support multi-tenant scenarios using the same configuration element, changing the connection attributes based on, for example, information coming from each request. Database Connector has connection providers that automatically set the driver class name and create JDBC URLs with given parameters for the following databases: - Derby - Microsoft SQL Server - MySQL - Oracle You can set up other JDBC databases using a generic JDBC configuration. Database Connector is JDBC compliant. Ensure that for the connection configuration, you use a driver that is compliant with JDBC to avoid compatibility issues. Additionally, you can reference a JDBC `DataSource` object or an `XADataSource` object, which is required for XA transactions, by creating the object in Anypoint Studio using Spring. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder Before creating an app, you must have access to the database target resource, Anypoint Platform, and have downloaded the proper database driver for your database. ## Common Use Cases for the Connector Database Connector enables you to: - Perform predefined queries, dynamically constructed queries, and template queries that are self-sufficient and customizable. - Specify DataWeave expressions in connector fields and configure attributes dynamically, depending on the database configuration you use. - Use a source listener operation to read from a database in the data source section of a flow. - Execute other operations to read and write to a database anywhere in the process section. - Perform multiple SQL requests in a single bulk update. - Make Data Definition Language (DDL) requests that alter the data structure rather than the data itself. - Execute stored procedures and SQL scripts. For examples, see [Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples). ## Audience - New users, read: - [Using Anypoint Studio to Configure the Connector](https://docs.mulesoft.com/db-connector/1.14/database-connector-studio) to create your Mule app - [Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples), which provide one or more use cases for the connector - Advanced users, read: - [XML and Maven Support](https://docs.mulesoft.com/db-connector/1.14/database-connector-xml-maven) - [Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples), which provide one or more use cases for the connector ## Using Exchange Templates and Examples [Anypoint Exchange](https://www.mulesoft.com/exchange/) provides templates that you can use as starting points for your apps and examples that illustrate a complete solution. - [Database Connector Examples](https://www.mulesoft.com/exchange/?search=database&type=example) - [Database Connector Templates](https://www.mulesoft.com/exchange/?search=database&type=template) ## Next Step After you complete the prerequisites and try the templates and examples, you are ready to create your own app and configure the connector using [Anypoint Studio](https://docs.mulesoft.com/db-connector/1.14/database-connector-studio). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Database Connector 1.15 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) establishes communication between your Mule app and a relational database. Database Connector can connect to almost any Java Database Connectivity (JDBC) relational database and run SQL operations. An application can support multi-tenant scenarios using the same configuration element, changing the connection attributes based on, for example, information coming from each request. Database Connector has connection providers that automatically set the driver class name and create JDBC URLs with given parameters for the following databases: - Derby - Microsoft SQL Server - MySQL - Oracle You can set up other JDBC databases using a generic JDBC configuration. Database Connector is JDBC compliant. Ensure that for the connection configuration, you use a driver that is compliant with JDBC to avoid compatibility issues. Additionally, you can reference a JDBC `DataSource` object or an `XADataSource` object, which is required for XA transactions, by creating the object in Anypoint Studio using Spring. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder Before creating an app, you must have access to the database target resource, Anypoint Platform, and have downloaded the proper database driver for your database. ## Common Use Cases for the Connector Database Connector enables you to: - Perform predefined queries, dynamically constructed queries, and template queries that are self-sufficient and customizable. - Specify DataWeave expressions in connector fields and configure attributes dynamically, depending on the database configuration you use. - Use a source listener operation to read from a database in the data source section of a flow. - Execute other operations to read and write to a database anywhere in the process section. - Perform multiple SQL requests in a single bulk update. - Make Data Definition Language (DDL) requests that alter the data structure rather than the data itself. - Execute stored procedures and SQL scripts. For examples, see [Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples). ## Audience - New users, read: - [Using Anypoint Studio to Configure the Connector](https://docs.mulesoft.com/db-connector/1.15/database-connector-studio) to create your Mule app - [Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples), which provide one or more use cases for the connector - Advanced users, read: - [XML and Maven Support](https://docs.mulesoft.com/db-connector/1.15/database-connector-xml-maven) - [Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples), which provide one or more use cases for the connector ## Using Exchange Templates and Examples [Anypoint Exchange](https://www.mulesoft.com/exchange/) provides templates that you can use as starting points for your apps and examples that illustrate a complete solution. - [Database Connector Examples](https://www.mulesoft.com/exchange/?search=database&type=example) - [Database Connector Templates](https://www.mulesoft.com/exchange/?search=database&type=template) ## Next Step After you complete the prerequisites and try the templates and examples, you are ready to create your own app and configure the connector using [Anypoint Studio](https://docs.mulesoft.com/db-connector/1.15/database-connector-studio). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Database Connector 1.16 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) establishes communication between your Mule app and a relational database. Database Connector can connect to almost any Java Database Connectivity (JDBC) relational database and run SQL operations. An application can support multi-tenant scenarios using the same configuration element, changing the connection attributes based on, for example, information coming from each request. Database Connector has connection providers that automatically set the driver class name and create JDBC URLs with given parameters for the following databases: - Derby - Microsoft SQL Server - MySQL - Oracle You can set up other JDBC databases using a generic JDBC configuration. Database Connector is JDBC compliant. Ensure that for the connection configuration, you use a driver that is compliant with JDBC to avoid compatibility issues. Additionally, you can reference a JDBC `DataSource` object or an `XADataSource` object, which is required for XA transactions, by creating the object in Anypoint Studio using Spring. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder Before creating an app, you must have access to the database target resource, Anypoint Platform, and have downloaded the proper database driver for your database. ## Common Use Cases for the Connector Database Connector enables you to: - Perform predefined queries, dynamically constructed queries, and template queries that are self-sufficient and customizable. - Specify DataWeave expressions in connector fields and configure attributes dynamically, depending on the database configuration you use. - Use a source listener operation to read from a database in the data source section of a flow. - Execute other operations to read and write to a database anywhere in the process section. - Perform multiple SQL requests in a single bulk update. - Make Data Definition Language (DDL) requests that alter the data structure rather than the data itself. - Execute stored procedures and SQL scripts. For examples, see [Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples). ## Audience - New users, read: - [Using Anypoint Studio to Configure the Connector](https://docs.mulesoft.com/db-connector/latest/database-connector-studio) to create your Mule app - [Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples), which provide one or more use cases for the connector - Advanced users, read: - [XML and Maven Support](https://docs.mulesoft.com/db-connector/latest/database-connector-xml-maven) - [Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples), which provide one or more use cases for the connector ## Using Exchange Templates and Examples [Anypoint Exchange](https://www.mulesoft.com/exchange/) provides templates that you can use as starting points for your apps and examples that illustrate a complete solution. - [Database Connector Examples](https://www.mulesoft.com/exchange/?search=database&type=example) - [Database Connector Templates](https://www.mulesoft.com/exchange/?search=database&type=template) ## Next Step After you complete the prerequisites and try the templates and examples, you are ready to create your own app and configure the connector using [Anypoint Studio](https://docs.mulesoft.com/db-connector/latest/database-connector-studio). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Database Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) examples help you configure database connections, query a database, execute stored procedures, execute DDL statements, execute scripts, execute database transactions, use bulk operations, and configure custom data types: - [Configure a Database Connection](https://docs.mulesoft.com/db-connector/1.14/database-connector-connection) Connect to both popular and generic database. Additionally, configure the connector to connect to a global data source, set a JDBC driver, configure connection pooling, and connection to an Oracle database with TNS. - [Configure an Oracle TLS Database Connection](https://docs.mulesoft.com/db-connector/1.14/database-connector-connection-secure-oracle) Connect to Oracle through a secure TPC (TCPS) tunnel using multiple secure Oracle connection levels and Mule’s TLS configuration. - [Configure Driver Visibility using Mule Maven Plugin](https://docs.mulesoft.com/db-connector/1.14/database-connector-driver-configuration) Use the Mule Maven Plugin to configure properly the driver classes visibility. - [Query a Database](https://docs.mulesoft.com/db-connector/1.14/database-connector-select) Configure the **Select** operation to query data from a database. - [Query a Single Record from a Database](https://docs.mulesoft.com/db-connector/1.14/database-connector-query-single) Configure the **Query single** operation in a Mule application that retrieves books information from a table in a MySQL database. - [Insert, Update, and Delete Data](https://docs.mulesoft.com/db-connector/1.14/database-insert-update-delete) Configure the **Insert**, **Update** and **Delete** operations to manage data. - [Bulk Insert, Bulk Update, and Bulk Delete Data from a Database](https://docs.mulesoft.com/db-connector/1.14/database-execute-bulk) Configure the **Bulk insert**, **Bulk update**, and **Bulk delete** operations to manage date in bulk. - [Execute Stored Procedures](https://docs.mulesoft.com/db-connector/1.14/database-stored-procedure) Configure the **Stored Procedure** operation to combine `input`, `output`, and `input-output` parameters. Additionally, configure dates on stored procedures. - [Call an Oracle Stored Procedure That Uses UDTs](https://docs.mulesoft.com/db-connector/1.14/database-connector-udt-stored-procedure) Configure the **Stored procedure** operation to call an Oracle database stored procedure that uses UDTs for its input and output parameters. Additionally, use `prepareStruct` and `prepareArray` DataWeave functions to map application data to your custom types. - [Execute DDL Statements](https://docs.mulesoft.com/db-connector/1.14/database-connector-execute-ddl) Configure the **Execute DDL** operation to execute DDL statements that create or modify data within tables or other data structures. - [Execute Scripts](https://docs.mulesoft.com/db-connector/1.14/database-execute-script) Configure the **Execute Script** operation to execute a script as a single statement. - [Configure Database Data Types](https://docs.mulesoft.com/db-connector/1.14/database-configure-data-types) Configure custom data types to use when connected to a particular connection provider. - [Configure Database Transactions](https://docs.mulesoft.com/db-connector/1.14/database-connector-transactions) Execute database operations in the context of a transaction. - [Insert large file content into a table](https://docs.mulesoft.com/db-connector/1.14/database-insert-large-clob) Configure a Mule app flow to read and insert a large file into a table. - [Using XA Transactions in Database Connector](https://docs.mulesoft.com/db-connector/1.14/database-connector-xa-transactions) Configure the **Use XA Transactions** field in the Database Connector global configuration so the datasource supports Extended Architecture Transactions (XA Transactions). - [Configure Use Bulk Copy for Database Connector SQL Server Connection](https://docs.mulesoft.com/db-connector/1.14/database-configure-usebulkcopy) Configure the Use Bulk Copy to do bulk copy operations when executing batch insert operations. - [Configure Azure Active Directory Authentication for MS SQL Server](https://docs.mulesoft.com/db-connector/1.14/database-connector-integratedsecurity) Configure Azure Active Directory Authentication for MS SQL Server using the Database Connector via the `IntegratedSecurity` parameter. - [Configuring Input and Output Parameters for Stored Procedures](https://docs.mulesoft.com/db-connector/1.14/database-connector-input-output-parameters) Configure input or output parameters for the **Stored procedure** operation of Anypoint Connector for Database (Database Connector) to specify the parameters that a stored procedure uses. ## See Also [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Database Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) examples help you configure database connections, query a database, execute stored procedures, execute DDL statements, execute scripts, execute database transactions, use bulk operations, and configure custom data types: - [Configure a Database Connection](https://docs.mulesoft.com/db-connector/1.15/database-connector-connection) Connect to both popular and generic database. Additionally, configure the connector to connect to a global data source, set a JDBC driver, configure connection pooling, and connection to an Oracle database with TNS. - [Configure an Oracle TLS Database Connection](https://docs.mulesoft.com/db-connector/1.15/database-connector-connection-secure-oracle) Connect to Oracle through a secure TPC (TCPS) tunnel using multiple secure Oracle connection levels and Mule’s TLS configuration. - [Configure Driver Visibility using Mule Maven Plugin](https://docs.mulesoft.com/db-connector/1.15/database-connector-driver-configuration) Use the Mule Maven Plugin to configure properly the driver classes visibility. - [Query a Database](https://docs.mulesoft.com/db-connector/1.15/database-connector-select) Configure the **Select** operation to query data from a database. - [Query a Single Record from a Database](https://docs.mulesoft.com/db-connector/1.15/database-connector-query-single) Configure the **Query single** operation in a Mule application that retrieves books information from a table in a MySQL database. - [Insert, Update, and Delete Data](https://docs.mulesoft.com/db-connector/1.15/database-insert-update-delete) Configure the **Insert**, **Update** and **Delete** operations to manage data. - [Bulk Insert, Bulk Update, and Bulk Delete Data from a Database](https://docs.mulesoft.com/db-connector/1.15/database-execute-bulk) Configure the **Bulk insert**, **Bulk update**, and **Bulk delete** operations to manage date in bulk. - [Execute Stored Procedures](https://docs.mulesoft.com/db-connector/1.15/database-stored-procedure) Configure the **Stored Procedure** operation to combine `input`, `output`, and `input-output` parameters. Additionally, configure dates on stored procedures. - [Call an Oracle Stored Procedure That Uses UDTs](https://docs.mulesoft.com/db-connector/1.15/database-connector-udt-stored-procedure) Configure the **Stored procedure** operation to call an Oracle database stored procedure that uses UDTs for its input and output parameters. Additionally, use `prepareStruct` and `prepareArray` DataWeave functions to map application data to your custom types. - [Execute DDL Statements](https://docs.mulesoft.com/db-connector/1.15/database-connector-execute-ddl) Configure the **Execute DDL** operation to execute DDL statements that create or modify data within tables or other data structures. - [Execute Scripts](https://docs.mulesoft.com/db-connector/1.15/database-execute-script) Configure the **Execute Script** operation to execute a script as a single statement. - [Configure Database Data Types](https://docs.mulesoft.com/db-connector/1.15/database-configure-data-types) Configure custom data types to use when connected to a particular connection provider. - [Configure Database Transactions](https://docs.mulesoft.com/db-connector/1.15/database-connector-transactions) Execute database operations in the context of a transaction. - [Insert large file content into a table](https://docs.mulesoft.com/db-connector/1.15/database-insert-large-clob) Configure a Mule app flow to read and insert a large file into a table. - [Using XA Transactions in Database Connector](https://docs.mulesoft.com/db-connector/1.15/database-connector-xa-transactions) Configure the **Use XA Transactions** field in the Database Connector global configuration so the datasource supports Extended Architecture Transactions (XA Transactions). - [Configure Use Bulk Copy for Database Connector SQL Server Connection](https://docs.mulesoft.com/db-connector/1.15/database-configure-usebulkcopy) Configure the Use Bulk Copy to do bulk copy operations when executing batch insert operations. - [Configure Azure Active Directory Authentication for MS SQL Server](https://docs.mulesoft.com/db-connector/1.15/database-connector-integratedsecurity) Configure Azure Active Directory Authentication for MS SQL Server using the Database Connector via the `IntegratedSecurity` parameter. - [Configuring Input and Output Parameters for Stored Procedures](https://docs.mulesoft.com/db-connector/1.15/database-connector-input-output-parameters) Configure input or output parameters for the **Stored procedure** operation of Anypoint Connector for Database (Database Connector) to specify the parameters that a stored procedure uses. ## See Also [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Database Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) examples help you configure database connections, query a database, execute stored procedures, execute DDL statements, execute scripts, execute database transactions, use bulk operations, and configure custom data types: - [Configure a Database Connection](https://docs.mulesoft.com/db-connector/latest/database-connector-connection) Connect to both popular and generic database. Additionally, configure the connector to connect to a global data source, set a JDBC driver, configure connection pooling, and connection to an Oracle database with TNS. - [Configure an Oracle TLS Database Connection](https://docs.mulesoft.com/db-connector/latest/database-connector-connection-secure-oracle) Connect to Oracle through a secure TPC (TCPS) tunnel using multiple secure Oracle connection levels and Mule’s TLS configuration. - [Configure Driver Visibility using Mule Maven Plugin](https://docs.mulesoft.com/db-connector/latest/database-connector-driver-configuration) Use the Mule Maven Plugin to configure properly the driver classes visibility. - [Query a Database](https://docs.mulesoft.com/db-connector/latest/database-connector-select) Configure the **Select** operation to query data from a database. - [Query a Single Record from a Database](https://docs.mulesoft.com/db-connector/latest/database-connector-query-single) Configure the **Query single** operation in a Mule application that retrieves books information from a table in a MySQL database. - [Insert, Update, and Delete Data](https://docs.mulesoft.com/db-connector/latest/database-insert-update-delete) Configure the **Insert**, **Update** and **Delete** operations to manage data. - [Bulk Insert, Bulk Update, and Bulk Delete Data from a Database](https://docs.mulesoft.com/db-connector/latest/database-execute-bulk) Configure the **Bulk insert**, **Bulk update**, and **Bulk delete** operations to manage date in bulk. - [Execute Stored Procedures](https://docs.mulesoft.com/db-connector/latest/database-stored-procedure) Configure the **Stored Procedure** operation to combine `input`, `output`, and `input-output` parameters. Additionally, configure dates on stored procedures. - [Call an Oracle Stored Procedure That Uses UDTs](https://docs.mulesoft.com/db-connector/latest/database-connector-udt-stored-procedure) Configure the **Stored procedure** operation to call an Oracle database stored procedure that uses UDTs for its input and output parameters. Additionally, use `prepareStruct` and `prepareArray` DataWeave functions to map application data to your custom types. - [Execute DDL Statements](https://docs.mulesoft.com/db-connector/latest/database-connector-execute-ddl) Configure the **Execute DDL** operation to execute DDL statements that create or modify data within tables or other data structures. - [Execute Scripts](https://docs.mulesoft.com/db-connector/latest/database-execute-script) Configure the **Execute Script** operation to execute a script as a single statement. - [Configure Database Data Types](https://docs.mulesoft.com/db-connector/latest/database-configure-data-types) Configure custom data types to use when connected to a particular connection provider. - [Configure Database Transactions](https://docs.mulesoft.com/db-connector/latest/database-connector-transactions) Execute database operations in the context of a transaction. - [Insert large file content into a table](https://docs.mulesoft.com/db-connector/latest/database-insert-large-clob) Configure a Mule app flow to read and insert a large file into a table. - [Using XA Transactions in Database Connector](https://docs.mulesoft.com/db-connector/latest/database-connector-xa-transactions) Configure the **Use XA Transactions** field in the Database Connector global configuration so the datasource supports Extended Architecture Transactions (XA Transactions). - [Configure Use Bulk Copy for Database Connector SQL Server Connection](https://docs.mulesoft.com/db-connector/latest/database-configure-usebulkcopy) Configure the Use Bulk Copy to do bulk copy operations when executing batch insert operations. - [Configure Azure Active Directory Authentication for MS SQL Server](https://docs.mulesoft.com/db-connector/latest/database-connector-integratedsecurity) Configure Azure Active Directory Authentication for MS SQL Server using the Database Connector via the `IntegratedSecurity` parameter. - [Configuring Input and Output Parameters for Stored Procedures](https://docs.mulesoft.com/db-connector/latest/database-connector-input-output-parameters) Configure input or output parameters for the **Stored procedure** operation of Anypoint Connector for Database (Database Connector) to specify the parameters that a stored procedure uses. ## See Also [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Database Connector Reference 1.14 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to connect to relational databases through the JDBC API. Release Notes: [Database Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-db) ## Configurations --- ### Default Configuration Use these parameters to configure the default configuration. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types to provide to this configuration.

x

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration. This does not mean that the platform expires the instance at the exact moment that it becomes eligible. Mule purges the instances as appropriate.

#### Connection Types ##### Data Source Reference Connection Configure the connection provider implementation that creates database connections from a referenced data source. When you use a _provider’s custom type_ in a Data Source Reference Connection, define the type inside the **Column Types** form of the Advanced section in the Database config. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Specifies non-standard column types

Data Source Ref

Any

Reference to a JDBC DataSource object. This object is typically created using Spring. When using XA transactions, an XADataSource object must be provided.

x

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

##### Derby Connection Use these parameters to create connections to a Derby database. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Specifies non-standard column types

Cache Query Template Size

Number

Sets the cache query template size for the connection.

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created data source must support XA transactions

false

Database

String

Name of the database

Subsub Protocol

String

Specifies where Derby should look for the database. The available options are:

  • directory

  • memory

  • classpath

  • jar

directory

Create

Boolean

Indicates whether to create the database if it does not already exist

false

Connection Properties

Object

Specifies a list of custom key-value connection properties for the configuration

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

##### Generic Connection Configure these parameters for the connection provider that creates connections for any kind of database using a JDBC URL and the required JDBC driver class. When you use a _provider’s custom type_ in a Generic Connection, define the type inside the **Column Types** form of the Advanced section in the Database config. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Specifies non-standard column types

Cache Query Template Size

Number

Sets the cache query template size for the connection.

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource must support XA transactions

false

URL

String

JDBC URL to use to connect to the database

x

Driver Class Name

String

Fully-qualified name of the database driver class

x

User

String

Database username

Password

String

Database password

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

##### Microsoft SQL Server Connection Configure these parameters for the database connection provider implementation for Microsoft SQL Server databases. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Specifies non-standard column types

Cache Query Template Size

Number

Sets the cache query template size for the connection.

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource must support XA transactions

false

Host

String

Configures the host of the database

x

Instance Name

String

Configures the name of the SQL server instance where the database is located

Port

Number

Configures the port of the database

User

String

The user to use for authentication against the database

Password

String

The password to use for authentication against the database

Database Name

String

Name of the default database to work with

Connection Properties

Object

Specifies a list of custom key-value connection properties for the configuration

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

##### MySQL Connection Configure these parameters to connect to a MySQL database. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Specifies non-standard column types

Cache Query Template Size

Number

Sets the cache query template size for the connection.

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource must support XA transactions

false

Host

String

Configures the host of the database

x

Port

Number

Configures the port of the database

x

User

String

The user to use for authentication against the database

Password

String

The password to use for authentication against the database

Database

String

The name of the database

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the configuration

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

##### Oracle Connection Configure these parameters to create connections to an Oracle database. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Specifies non-standard column types

Cache Query Template Size

Number

Sets the cache query template size for the connection.

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting to the database

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource must support XA transactions

false

Host

String

Configures the host of the database

x

Port

Number

Configures the port of the database

1521

User

String

The user to use for authentication against the database

Password

String

The password to use for authentication against the database

Instance

String

The name of the database instance

Service Name

String

The name of the database service name

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

## Operations > [!NOTE] To incorporate an SQL function within an operation’s query, use the `{fn function()}` > syntax. This constitutes a JDBC escape call. For instance, `CURRENT_TIMESTAMP` must be written as > `{fn CURRENT_TIMESTAMP()}`. - [Bulk Delete](#bulkDelete) - [Bulk Insert](#bulkInsert) - [Bulk Update](#bulkUpdate) - [Delete](#delete) - [Execute DDL](#executeDdl) - [Execute Script](#executeScript) - [Insert](#insert) - [Select](#select) - [Query Single](#querySingle) - [Stored Procedure](#storedProcedure) - [Update](#update) ## Associated Sources - [On Table Row](#listener) ### Bulk Delete `` This operation allows delete operations to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing a single delete operation at various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Input Parameters

Array of Object

Specifies a list of maps, which contain the parameter names as keys and the value the parameter is bound to, and in which every list item represents a row to insert.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is true, in which case a default value of 10 is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

This parameter allows you to optionally specify the type of one or more of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Array of Number

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Bulk Insert `` This operation allows inserts to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing a single insert operation at various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Input Parameters

Array of Object

A list of maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows you to optionally specify the type of one or more of the parameters in the query. If provided, you’re not required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

The name of a variable to store the operation’s output.

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Bulk Update `` This operation allows updates to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing one single update operation at various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Input Parameters

Array of Object

Specifies a list of maps, which contain the parameter names as keys and the value the parameter is bound to, and in which every list item represents a row to insert.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows you to optionally specify the type of one or more of the parameters in the query. If provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Array of Number

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Delete `` This operation deletes data in a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows you to optionally specify the type of one or more of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Input Parameters

Object

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (for example, where id = :myParamName). The map’s values contain the actual assignation for each parameter.

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Number

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Execute DDL `` This operation allows execution of DDL queries against a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

SQL Query Text

String

The text of the SQL query to execute

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Number

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Execute Script `` This operation executes an SQL script in a single database statement. The script is executed as provided by the user, without any parameter binding. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take for transactions.

JOIN_IF_POSSIBLE

SQL Query Text

String

The text of the SQL query to execute

Script Path

String

Specifies the location of a file to load. The file can point to a resource on the classpath, or on a disk.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Array of Number

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Insert `` This operation inserts data into a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows you to optionally specify the type of one or more of the parameters in the query. If provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Input Parameters

Object

A map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (E.g: where id = :myParamName)). The map’s values contain the actual assignation for each parameter.

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys to make available for retrieval

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Statement Result

### For Configurations - [Default Configuration](#config) #### Throws - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Select `` This operation queries data from a database. To prevent loading all the results at once, which can lead to performance and memory issues, results are automatically streamed. This means that pages of _fetchSize_ rows are loaded when needed. If this operation is performed inside a transaction (that is, within a **Try** scope component) and that transaction is closed before consuming the data, accessing the results that haven’t been loaded will fail. Some drivers, however, load the entire result upon query execution, which means streaming does not work. For example, sometimes Postgres drivers load the entire result into memory. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions

JOIN_IF_POSSIBLE

Streaming Strategy

Configure to use repeatable streams

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows you to optionally specify the type of one or more of the parameters in the query. If provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Input Parameters

Object

A map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (for example: where id = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

The name of a variable to store the operation’s output.

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Array of Object

### For Configurations - [Default Configuration](#config) ### Working with Pooling Profiles When working with pooling profiles and the **Select** operation, the connection remains open until one of the following occurs: - The flow execution ends - The content of the streams are consumed completely - The connection is the transaction key. > [!NOTE] Because LOBs are treated as streams, the connection remains open until the flow execution > ends, or until the content is consumed before the flow completes, in which case the best approach > is taken to close the related connection. This behavior occurs because the result set the operation generates can have a stream or be part of an ongoing transaction. #### Throws - DB:BAD\_SQL\_SYNTAX - DB:CONNECTIVITY - DB:QUERY\_EXECUTION ### Query Single `` This operation selects a single data record from a database. If you provide an SQL query that returns more than one row, then only the first record is processed and returned. This operation does not use streaming, which means that immediately after performing the Query Single operation, the complete content of the selected record is loaded into memory. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of join action that operations can take regarding transactions

JOIN_IF_POSSIBLE

Streaming Strategy

Configure to use repeatable streams

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

The maximum number of rows that any ResultSet object generated by this message processor can contain. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Enables you to optionally specify the type of one or more of the parameters in the query. If provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Input Parameters

Object

A map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (for example: where id = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable in which to store the operation’s output

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Default Configuration](#config) ### Working with Pooling Profiles When working with pooling profiles and the Query Single operation, the connection returns to the pool immediately after the operation is performed. #### Throws - DB:BAD\_SQL\_SYNTAX - DB:CONNECTIVITY - DB:QUERY\_EXECUTION ### Stored Procedure `` Invokes a stored procedure on the database. When the stored procedure returns one or more ResultSet instances, results are not read all at once. Instead, results are automatically streamed to prevent performance and memory issues. This behavior means that pages of `_fetchSize_` rows are loaded lazily when needed. If the **Stored procedure** operation is performed inside a transaction (for example, in a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded will fail. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. > [!NOTE] Database Connector doesn’t support Oracle primitive LOB collections (for example, > VARRAY/NESTED TABLE of BLOB/CLOB) in stored procedures. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Streaming Strategy

Configure to use repeatable streams

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (for example: where id = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Input - Output Parameters

Object

A map in which keys are the name of a parameter to be set on the JDBC prepared statement which is both input and output. Each parameter should be referenced in the SQL text using a colon prefix (for example: where id = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Output Parameters

A list of output parameters to be set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (for example: call multiply(:value, :result))

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

The name of a variable to store the operation’s output.

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Object

### For Configurations - [Default Configuration](#config) ### Working with Pooling Profiles When working with pooling profiles and the **Stored procedure** operation, the connection remains open until the flow execution ends or the content of the streams are consumed completely, or if the connection is the transaction key. This behavior occurs because the resultset the operation generates can have a stream or be part of an ongoing transaction. Starting with Database Connector 1.8.3, the connections on the **Stored procedure** operation are released if they are not part of a stream or transaction. #### Throws - DB:BAD\_SQL\_SYNTAX - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED ### Update `` Updates data in a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take for transactions

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows you to optionally specify the type of one or more of the parameters in the query. If provided, you’re not required to reference all of the parameters; but you cannot reference a parameter that is not present in the input values.

Input Parameters

Object

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter should be referenced in the SQL text using a colon prefix (for example: where id = :myParamName)). The map’s values contain the actual assignation for each parameter.

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval

Target Variable

String

The name of a variable to store the operation’s output

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors

#### Output

Type

Statement Result

### For Configurations - [Default Configuration](#config) #### Throws - DB:BAD\_SQL\_SYNTAX - DB:CONNECTIVITY - DB:QUERY\_EXECUTION - DB:RETRY\_EXHAUSTED ## Sources ### On Table Row `` This operation selects from a table at a regular interval and generates one message per obtained row. Optionally, you can provide watermark and ID columns. If a watermark column is provided, the values taken from that column are used to filter the contents of the next poll, so that only rows with a greater watermark value are returned. If an ID column is provided, this component automatically verifies that the same row is not picked twice by concurrent polls. This operation does not support streaming, meaning that there is no need to perform additional transformations to the payload in order to access the operation results. This behavior is identical to the **Query Single** operation released in version 1.9. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use

x

Table

String

The name of the table to select from

x

Watermark Column

String

The name of the column to use for a watermark. Values taken from this column are used to filter the contents of the next poll, so that only rows with a greater watermark value are processed.

Id Column

String

The name of the column to consider as the row ID. If provided, this component makes sure that the same row is not processed twice by concurrent polls.

Transactional Action

Enumeration, one of:

  • ALWAYS_BEGIN

  • NONE

The type of beginning action that sources can take regarding transactions

NONE

Transaction Type

Enumeration, one of:

  • LOCAL

  • XA

The type of transaction to create. Availability depends on the runtime version.

LOCAL

Primary Node Only

Boolean

Whether this source should be executed only on the primary node when running in a cluster

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling

x

Redelivery Policy

Defines a policy for processing the redelivery of the same message

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout is used.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the #queryTimeout. Values specified in nanoseconds, microseconds, or milliseconds are rounded to seconds.

SECONDS

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a ResultSet.

10

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Default Configuration](#config) ## Types ### Pooling Profile
FieldTypeDescriptionDefault ValueRequired

Max Pool Size

Number

Maximum number of connections a pool maintains at any given time

5

Min Pool Size

Number

Minimum number of connections a pool maintains at any given time

0

Acquire Increment

Number

Determines how many connections at a time to try to acquire when the pool is exhausted

1

Prepared Statement Cache Size

Number

Determines how many statements are cached per pooled connection. Setting this to zero disables statement caching.

5

Max Wait

Number

The amount of time a client trying to obtain a connection waits for it to be acquired when the pool is exhausted. Setting this value to zero (default) means wait indefinitely. This is equivalent to checkoutTimeout and cannot be overridden in additional-properties.

0

Max Wait Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A #maxWait.

SECONDS

Max Idle Time

Number

Determines how many seconds a connection can remain pooled but unused before being discarded. Setting this value to zero (default) means idle connections never expire.

0

Additional Properties

Object

A map in which keys are the name of a pooling profile configuration property. Does not support the use of expressions. These properties cannot be used to override any of the previously specified properties (like Max Pool Size or Min Pool Size), the main property prevails if an attempt is made to override it. The map’s values contain the actual assignation for each parameter. Use this field to add any additional connection pool property.

Max Statement

Number

Defines the total number PreparedStatements a DataSource will cache. The pool destroys the least-recently-used PreparedStatement when it reaches the specified limit. When set to 0, statement caching is turned off

Test connection on checkout

Boolean

Disables connection testing on checkout to improve performance. If set to true, an operation is performed at every connection checkout to verify that the connection is valid.

true

### Column Type
FieldTypeDescriptionDefault ValueRequired

Id

Number

Type identifier used by the JDBC driver

x

Type Name

String

Name of the data type used by the JDBC driver

x

Class Name

String

Indicates which Java class must be used to map the database type

### Reconnection
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Reconnection Strategy

The reconnection strategy to use

### Reconnect
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often to reconnect (in milliseconds)

Count

Number

The number of reconnection attempts to make

blocking

Boolean

If set to false, the reconnection strategy runs in a separate, non-blocking thread

true

### Reconnect Forever
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often in milliseconds to reconnect

blocking

Boolean

If set to false, the reconnection strategy runs in a separate, non-blocking thread

true

### Tls
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

A comma-separated list of protocols enabled for this context.

Enabled Cipher Suites

String

A comma-separated list of cipher suites enabled for this context.

Trust Store

Key Store

Revocation Check

### Trust Store
FieldTypeDescriptionDefault ValueRequired

Path

String

The location (which will be resolved relative to the current classpath and file system, if possible) of the trust store.

Password

String

The password used to protect the trust store.

Type

String

The type of store used.

Algorithm

String

The algorithm used by the trust store.

Insecure

Boolean

If true, no certificate validations will be performed, rendering connections vulnerable to attacks. Use at your own risk.

### Key Store
FieldTypeDescriptionDefault ValueRequired

Path

String

The location (which will be resolved relative to the current classpath and file system, if possible) of the key store.

Type

String

The type of store used.

Alias

String

When the key store contains many private keys, this attribute indicates the alias of the key that should be used. If not defined, the first key in the file will be used by default.

Key Password

String

The password used to protect the private key.

Password

String

The password used to protect the key store.

Algorithm

String

The algorithm used by the key store.

### Standard Revocation Check
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Only verify the last element of the certificate chain.

Prefer Crls

Boolean

Try CRL instead of OCSP first.

No Fallback

Boolean

Do not use the secondary checking method (the one not selected before).

Soft Fail

Boolean

Avoid verification failure when the revocation server can not be reached or is busy.

### Custom Ocsp Responder
FieldTypeDescriptionDefault ValueRequired

Url

String

The URL of the OCSP responder.

Cert Alias

String

Alias of the signing certificate for the OCSP response (must be in the trust store), if present.

### Crl File
FieldTypeDescriptionDefault ValueRequired

Path

String

The path to the CRL file.

### Expiration Policy
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

A scalar time value for the maximum amount of time a dynamic configuration instance should be allowed to be idle before it’s considered eligible for expiration

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the maxIdleTime attribute

### Redelivery Policy
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

The maximum number of times a message can be redelivered and processed unsuccessfully before triggering a process-failed-message

Use Secure Hash

Boolean

Whether to use a secure hash algorithm to identify a redelivered message.

Message Digest Algorithm

String

The secure hashing algorithm to use. If this is not set, the default is SHA-256.

SHA-256

Id Expression

String

Defines one or more expressions to use to determine when a message has been redelivered. This property can be set only if Use secure hash is set to false.

Object Store

Object Store

The object store where the redelivery counter for each message is stored

### Parameter Type
FieldTypeDescriptionDefault ValueRequired

Key

String

The name of the input parameter

x

Type Classifier

x

### Type Classifier
FieldTypeDescriptionDefault ValueRequired

Type

Enumeration, one of:

  • BIT

  • TINYINT

  • SMALLINT

  • INTEGER

  • BIGINT

  • FLOAT

  • REAL

  • DOUBLE

  • NUMERIC

  • DECIMAL

  • CHAR

  • VARCHAR

  • LONGVARCHAR

  • DATE

  • TIME

  • TIMESTAMP

  • BINARY

  • VARBINARY

  • LONGVARBINARY

  • NULL

  • OTHER

  • JAVA_OBJECT

  • DISTINCT

  • STRUCT

  • ARRAY

  • BLOB

  • CLOB

  • REF

  • DATALINK

  • BOOLEAN

  • ROWID

  • NCHAR

  • NVARCHAR

  • LONGNVARCHAR

  • NCLOB

  • SQLXML

  • UNKNOWN

Custom Type

String

### Statement Result
FieldTypeDescriptionDefault ValueRequired

Affected Rows

Number

Generated Keys

Object

### Repeatable In Memory Iterable
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

The number of instances that are initially allowed to be kept in memory to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then the buffer expands according to the Buffer size increment attribute, with an upper limit of Max in memory size. The default value is 100 instances.

100

Buffer Size Increment

Number

Specifies by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, in which case a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full. The default value is 100 instances.

100

Max Buffer Size

Number

The maximum amount of memory to use. If more than the specified maximum amount of memory is used, then a `STREAM_MAXIMUM_SIZE_EXCEEDE`D error is raised. A value lower than, or equal to, zero means no limit.

### Repeatable File Store Iterable
FieldTypeDescriptionDefault ValueRequired

In Memory Objects

Number

The maximum number of instances to keep in memory. If more than the specified maximum is required, then content starts to buffer on disk.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which maxInMemorySize is expressed

### Repeatable In Memory Stream
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

The number of instances that are initially allowed to be kept in memory to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then the buffer expands according to the Buffer size increment attribute, with an upper limit of Max in memory size

Buffer Size Increment

Number

Specifies by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, in which case a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full

Max Buffer Size

Number

The maximum amount of memory to use. If more than the specified maximum amount of memory is used, then a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised. A value lower than, or equal to, zero means no limit.

Buffer Unit

Enumeration, one of: BYTE KB MB GB

The unit in which all these attributes are expressed

### Repeatable File Store Stream
FieldTypeDescriptionDefault ValueRequired

In Memory Size

Number

Defines the maximum memory that the stream should use to keep data in memory. If more than that is consumed content on the disk is buffered.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which Max in memory size is expressed

### Output Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

The name of the input parameter

x

Type Classifier

x

## System Properties
PropertyDescriptionDefault ValueExample

mule.db.commons.defaultParamTypeResolver.enable.fallback

This system property handles special characters in stored procedure names, providing an alternative configuration method when these characters are present.

false

-M-Dmule.db.commons.defaultParamTypeResolver.enable.fallback=true

## See Also [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Database Connector Reference 1.15 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to connect to relational databases through the JDBC API. Release Notes: [Database Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-db) ## Configurations --- ### Config Default configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

Name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types to provide to this configuration.

x

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

#### Connection Types ##### Data Source Reference Connection ConnectionProvider implementation which creates DB connections from a referenced DataSource ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

50

Data Source Ref

Any

x

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Derby Connection Creates connections to a Derby database ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Database

String

Name of the database

Subsub Protocol

String

Specifies where Derby should look for the database. The available options are: 'directory', 'memory', 'classpath' and 'jar'.

directory

Create

Boolean

Indicates if the database should be created if it does not exist.

false

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the config.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Generic Connection ConnectionProvider that creates connections for any kind of database using a JDBC URL and the required JDBC Driver Class ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

NOT_CONFIGURED

Use XA Transactions

Boolean

false

URL

String

x

Driver Class Name

String

x

User

String

Password

String

Password to authenticate against the proxy server.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Microsoft SQL Server Connection DbConnectionProvider implementation for Microsoft SQL Server Databases ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Host

String

Configures the host of the database.

x

Instance Name

String

Configures the name of the SQL server instance where the database is.

Port

Number

Configures the port of the database.

User

String

The user to use for authentication against the database.

Password

String

The password to use for authentication against the database.

Database Name

String

Name of the default database to work with.

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the config.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### MySQL Connection Creates connections to a MySQL database. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Host

String

Configures the host of the database.

x

Port

Number

Configures the port of the database.

x

User

String

The user to use for authentication against the database.

Password

String

The password to use for authentication against the database.

Database

String

The name of the database.

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the config.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Oracle Connection Creates connections to a Oracle database ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

50

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Host

String

Configures the host of the database.

x

Port

Number

Configures the port of the database.

1521

User

String

The user to use for authentication against the database.

Password

String

The password to use for authentication against the database.

Instance

String

The name of the database instance.

Service Name

String

The name of the database service name.

TLS Context

The TLS factory used to create TLS secured connections

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

## Supported Operations - [Bulk Delete](#bulkDelete) - [Bulk Insert](#bulkInsert) - [Bulk Update](#bulkUpdate) - [Delete](#delete) - [Execute DDL](#executeDdl) - [Execute Script](#executeScript) - [Insert](#insert) - [Query Single](#querySingle) - [Select](#select) - [Stored Procedure](#storedProcedure) - [Update](#update) ## Associated Sources - [On Table Row](#listener) ## Operations ### Bulk Delete `` Allows executing one delete statement various times using different parameter bindings. This happens using one single Database statement, which has performance advantages compared to executing one single delete operation various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Input Parameters

Array of Object

A List of Maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Bulk Insert `` Allows executing one insert statement various times using different parameter bindings. This happens using one single Database statement, which has performance advantages compared to executing one single update operation various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Input Parameters

Array of Object

A List of Maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Bulk Update `` Allows executing one update statement various times using different parameter bindings. This happens using one single Database statement, which has performance advantages compared to executing one single update operation various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Input Parameters

Array of Object

A List of Maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Delete `` Deletes data in a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Execute DDL `` Enables execution of DDL queries against a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

SQL Query Text

String

The text of the SQL query to execute

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Execute Script `` Executes a SQL script in one single Database statement. The script is executed as provided by the user, without any parameter binding. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

SQL Query Text

String

The text of the SQL query to execute

Script Path

String

The location of a file to load. The file can point to a resource on the classpath or on a disk.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Insert `` Inserts data into a Database #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Statement Result

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Query Single `` Selects single result from a database. If the indicated SQL query returns more than one record, only the first one is returned. Streaming is not used for this operation, which means that you must be careful because all selected fields will be loaded to memory. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Select `` Selects data from a database. Streaming is automatically applied to avoid preemptive consumption of such results, which may lead to performance and memory issues. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Object

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:BAD\_SQL\_SYNTAX ### Stored Procedure `` Invokes a Stored Procedure on the database. When the stored procedure returns one or more ResultSet instances, streaming is automatically applied to avoid preemptive consumption of such results, which may lead to performance and memory issues. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. > [!NOTE] Database Connector doesn’t support Oracle primitive LOB collections (for example, > VARRAY/NESTED TABLE of BLOB/CLOB) in stored procedures. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Input - Output Parameters

Object

A Map which keys are the name of a parameter to be set on the JDBC prepared statement which is both input and output. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Output Parameters

A list of output parameters to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: call multiply(:value, :result))

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Update `` Updates data in a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Statement Result

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ## Sources ### On Table Row `` Selects from a table at a regular interval and generates one message per each obtained row. Optionally, watermark and ID columns can be provided. If a watermark column is provided, the values taken from that column will be used to filter the contents of the next poll, so that only rows with a greater watermark value are returned. If an ID column is provided, this component will automatically make sure that the same row is not picked twice by concurrent polls #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Table

String

The name of the table to select from

x

Watermark Column

String

The name of the column to use for watermark. Values taken from this column will be used to filter the contents of the next poll, so that only rows with a greater watermark value are processed.

Id Column

String

The name of the column to consider as row ID. If provided, this component will make sure that the same row is not processed twice by concurrent polls.

Transactional Action

Enumeration, one of:

  • ALWAYS_BEGIN

  • NONE

The type of beginning action that sources can take regarding transactions.

NONE

Transaction Type

Enumeration, one of:

  • LOCAL

  • XA

The type of transaction to create. Availability depends on Mule version.

LOCAL

Primary Node Only

Boolean

Determines whether to execute this source on only the primary node when running Mule instances in a cluster. When deployed in a clustered environment with multiple workers, this must be enabled to prevent duplicate record processing.

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling.

x

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Config](#config) ## Types ### Pooling Profile
FieldTypeDescriptionDefault ValueRequired

Max Pool Size

Number

Maximum number of connections a pool maintains at any given time.

5

Min Pool Size

Number

Minimum number of connections a pool maintains at any given time.

0

Acquire Increment

Number

Determines how many connections at a time to try to acquire when the pool is exhausted.

1

Prepared Statement Cache Size

Number

Determines how many statements are cached per pooled connection.

5

Max Wait

Number

The amount of time a client calling getConnection() waits for a connection to be checked-in or acquired when the pool is exhausted. A value of 0 means wait indefinitely.

0

Max Wait Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the Max Wait.

SECONDS

Max Idle Time

Number

The number of seconds that a connection can remain pooled but unused before being discarded. A value of 0 means idle connections never expire.

0

Max Statements

Number

Deprecated. Always set to 0.

0

Test Connection On Checkout

Boolean

If true, an operation is performed at every connection checkout to verify that the connection is valid.

true

Additional Properties

Object

Specifies additional properties for the data source connection pool.

### Column Type
FieldTypeDescriptionDefault ValueRequired

Id

Number

x

Type Name

String

x

Class Name

String

### Reconnection Configures a reconnection strategy for an operation.
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Reconnection Strategy

Reconnection strategy to use.

### Reconnect
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often to attempt to reconnect, in milliseconds.

Count

Number

How many reconnection attempts the Mule app can make.

### Reconnect Forever
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often to attempt to reconnect, in milliseconds.

### TLS Configures TLS to provide secure communications for the Mule app.
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

Comma-separated list of protocols enabled for this context.

Enabled Cipher Suites

String

Comma-separated list of cipher suites enabled for this context.

Trust Store

Configures the TLS truststore.

Key Store

Configures the TLS keystore.

Revocation Check

### Truststore Configures the truststore for TLS.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the truststore. Mule resolves the path relative to the current classpath and file system.

Password

String

Password used to protect the truststore.

Type

String

Type of store.

Algorithm

String

Encryption algorithm that the truststore uses.

Insecure

Boolean

If true, Mule stops performing certificate validations. Setting this to true can make connections vulnerable to attacks.

### Keystore Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the keystore. Mule resolves the path relative to the current classpath and file system.

Type

String

Type of store.

Alias

String

Alias of the key to use when the keystore contains multiple private keys. By default, Mule uses the first key in the file.

Key Password

String

Password used to protect the private key.

Password

String

Password used to protect the keystore.

Algorithm

String

Encryption algorithm that the keystore uses.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Which elements to verify in the certificate chain:

  • true

Verify only the last element in the certificate chain.

  • false

Verify all elements in the certificate chain.

Prefer Crls

Boolean

How to check certificate validity:

  • true

Check the Certification Revocation List (CRL) for certificate validity.

  • false

Use the Online Certificate Status Protocol (OCSP) to check certificate validity.

No Fallback

Boolean

Whether to use the secondary method to check certificate validity:

  • true

Use the method that wasn’t specified in the Prefer Crls field (the secondary method) to check certificate validity.

  • false

Do not use the secondary method to check certificate validity.

Soft Fail

Boolean

What to do if the revocation server can’t be reached or is busy:

  • true

Avoid verification failure.

  • false

Allow the verification to fail.

### Custom OCSP Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

URL of the OCSP responder.

Cert Alias

String

Alias of the signing certificate for the OCSP response. If specified, the alias must be in the truststore.

### CRL File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the CRL file.

### Expiration Policy Configures an expiration policy strategy.
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

Configures the maximum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Time unit for the Max Idle Time field.

### Redelivery Policy Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

Maximum number of times that a redelivered request can be processed unsuccessfully before returning a REDELIVERY_EXHAUSTED error.

Use Secure Hash

Boolean

If true, Mule uses a secure hash algorithm to identify a redelivered message.

Message Digest Algorithm

String

Secure hashing algorithm to use if the Use Secure Hash field is true. If the payload of the message is a Java object, Mule ignores this value and returns the value that the payload’s hashCode() returned.

Id Expression

String

One or more expressions that determine when a message was redelivered. You can set this property only if the Use Secure Hash field is false.

Object Store

Object Store

Configures the object store that stores the redelivery counter for each message.

### Parameter Type
FieldTypeDescriptionDefault ValueRequired

Key

String

The name of the input parameter.

x

Type Classifier

x

### Type Classifier
FieldTypeDescriptionDefault ValueRequired

Type

Enumeration, one of:

  • BIT

  • TINYINT

  • SMALLINT

  • INTEGER

  • BIGINT

  • FLOAT

  • REAL

  • DOUBLE

  • NUMERIC

  • DECIMAL

  • CHAR

  • VARCHAR

  • LONGVARCHAR

  • DATE

  • TIME

  • TIMESTAMP

  • BINARY

  • VARBINARY

  • LONGVARBINARY

  • NULL

  • OTHER

  • JAVA_OBJECT

  • DISTINCT

  • STRUCT

  • ARRAY

  • BLOB

  • CLOB

  • REF

  • DATALINK

  • BOOLEAN

  • ROWID

  • NCHAR

  • NVARCHAR

  • LONGNVARCHAR

  • NCLOB

  • SQLXML

  • REF_CURSOR

  • UNKNOWN

Custom Type

String

### Statement Result
FieldTypeDescriptionDefault ValueRequired

Affected Rows

Number

Generated Keys

Object

### Repeatable In Memory Iterable
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

The amount of instances that is initially be allowed to be kept in memory to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then the buffer expands according to the bufferSizeIncrement attribute, with an upper limit of maxInMemorySize. Default value is 100 instances.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full. Default value is 100 instances.

Max Buffer Size

Number

Maximum size of the buffer. If the buffer size exceeds this value, Mule raises a STREAM_MAXIMUM_SIZE_EXCEEDED error. A value of less than or equal to 0 means no limit.

### Repeatable File Store Iterable
FieldTypeDescriptionDefault ValueRequired

In Memory Objects

Number

The maximum amount of instances to keep in memory. If more than that is required, content on the disk is buffered.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the In Memory Size field.

### Repeatable In Memory Stream Configures the in-memory streaming strategy by which the request fails if the data exceeds the MAX buffer size. Always run performance tests to find the optimal buffer size for your specific use case.
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

Initial amount of memory to allocate to the data stream. If the streamed data exceeds this value, the buffer expands by Buffer Size Increment, with an upper limit of Max In Memory Size value.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full.

Max Buffer Size

Number

Maximum size of the buffer. If the buffer size exceeds this value, Mule raises a STREAM_MAXIMUM_SIZE_EXCEEDED error. A value of less than or equal to 0 means no limit.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the Initial Buffer Size, Buffer Size Increment, and Buffer Unit fields.

### Repeatable File Store Stream Configures the repeatable file-store streaming strategy by which Mule keeps a portion of the stream content in memory. If the stream content is larger than the configured buffer size, Mule backs up the buffer’s content to disk and then clears the memory.
FieldTypeDescriptionDefault ValueRequired

In Memory Size

Number

Maximum amount of memory that the stream can use for data. If the amount of memory exceeds this value, Mule buffers the content to disk. To optimize performance:

  • Configure a larger buffer size to avoid the number of times Mule needs to write the buffer on disk. This increases performance, but it also limits the number of concurrent requests your application can process, because it requires additional memory.

  • Configure a smaller buffer size to decrease memory load at the expense of response time.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the In Memory Size field.

### Output Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

The name of the input parameter.

x

Type Classifier

x

--- product: Database Connector version: 1.16 is-latest-version: true --- # Database Connector Reference 1.16 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) enables you to connect to relational databases through the JDBC API. Release Notes: [Database Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-db) ## Configurations --- ### Config Default configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

Name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types to provide to this configuration.

x

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

#### Connection Types ##### Data Source Reference Connection ConnectionProvider implementation which creates DB connections from a referenced DataSource ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

1000

Data Source Ref

Any

x

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Derby Connection Creates connections to a Derby database ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

1000

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Database

String

Name of the database

Subsub Protocol

String

Specifies where Derby should look for the database. The available options are: 'directory', 'memory', 'classpath' and 'jar'.

directory

Create

Boolean

Indicates if the database should be created if it does not exist.

false

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the config.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Generic Connection ConnectionProvider that creates connections for any kind of database using a JDBC URL and the required JDBC Driver Class ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

1000

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

NOT_CONFIGURED

Use XA Transactions

Boolean

false

URL

String

x

Driver Class Name

String

x

User

String

Password

String

Password to authenticate against the proxy server.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Microsoft SQL Server Connection DbConnectionProvider implementation for Microsoft SQL Server Databases ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

1000

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Host

String

Configures the host of the database.

x

Instance Name

String

Configures the name of the SQL server instance where the database is.

Port

Number

Configures the port of the database.

User

String

The user to use for authentication against the database.

Password

String

The password to use for authentication against the database.

Database Name

String

Name of the default database to work with.

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the config.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### MySQL Connection Creates connections to a MySQL database. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

1000

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Host

String

Configures the host of the database.

x

Port

Number

Configures the port of the database.

x

User

String

The user to use for authentication against the database.

Password

String

The password to use for authentication against the database.

Database

String

The name of the database.

Connection Properties

Object

Specifies a list of custom key-value connectionProperties for the config.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

##### Oracle Connection Creates connections to a Oracle database ###### Parameters
NameTypeDescriptionDefault ValueRequired

Pooling Profile

Configures the database connection pooling.

Column Types

Array of Column Type

Cache Query Template Size

Number

1000

Transaction Isolation

Enumeration, one of:

  • NONE

  • READ_COMMITTED

  • READ_UNCOMMITTED

  • REPEATABLE_READ

  • SERIALIZABLE

  • NOT_CONFIGURED

The transaction isolation level to set on the driver when connecting the database.

NOT_CONFIGURED

Use XA Transactions

Boolean

Indicates whether or not the created datasource has to support XA transactions. Default is false.

false

Host

String

Configures the host of the database.

x

Port

Number

Configures the port of the database.

1521

User

String

The user to use for authentication against the database.

Password

String

The password to use for authentication against the database.

Instance

String

The name of the database instance.

Service Name

String

The name of the database service name.

TLS Context

The TLS factory used to create TLS secured connections

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

## Supported Operations - [Bulk Delete](#bulkDelete) - [Bulk Insert](#bulkInsert) - [Bulk Update](#bulkUpdate) - [Delete](#delete) - [Execute DDL](#executeDdl) - [Execute Script](#executeScript) - [Insert](#insert) - [Query Single](#querySingle) - [Select](#select) - [Stored Procedure](#storedProcedure) - [Update](#update) ## Associated Sources - [On Table Row](#listener) ## Operations ### Bulk Delete `` Allows executing one delete statement various times using different parameter bindings. This happens using one single Database statement, which has performance advantages compared to executing one single delete operation various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Input Parameters

Array of Object

A List of Maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Bulk Insert `` Allows executing one insert statement various times using different parameter bindings. This happens using one single Database statement, which has performance advantages compared to executing one single update operation various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Input Parameters

Array of Object

A List of Maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Bulk Update `` Allows executing one update statement various times using different parameter bindings. This happens using one single Database statement, which has performance advantages compared to executing one single update operation various times. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Input Parameters

Array of Object

A List of Maps in which every list item represents a row to be inserted, and the map contains the parameter names as keys and the value the parameter is bound to.

#[payload]

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Delete `` Deletes data in a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Execute DDL `` Enables execution of DDL queries against a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

SQL Query Text

String

The text of the SQL query to execute

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Execute Script `` Executes a SQL script in one single Database statement. The script is executed as provided by the user, without any parameter binding. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

SQL Query Text

String

The text of the SQL query to execute

Script Path

String

The location of a file to load. The file can point to a resource on the classpath or on a disk.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Number

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Insert `` Inserts data into a Database #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Statement Result

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Query Single `` Selects single result from a database. If the indicated SQL query returns more than one record, only the first one is returned. Streaming is not used for this operation, which means that you must be careful because all selected fields will be loaded to memory. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Select `` Selects data from a database. Streaming is automatically applied to avoid preemptive consumption of such results, which may lead to performance and memory issues. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Array of Object

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:BAD\_SQL\_SYNTAX ### Stored Procedure `` Invokes a Stored Procedure on the database. When the stored procedure returns one or more ResultSet instances, streaming is automatically applied to avoid preemptive consumption of such results, which may lead to performance and memory issues. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. > [!NOTE] Database Connector doesn’t support Oracle primitive LOB collections (for example, > VARRAY/NESTED TABLE of BLOB/CLOB) in stored procedures. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Input - Output Parameters

Object

A Map which keys are the name of a parameter to be set on the JDBC prepared statement which is both input and output. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Output Parameters

A list of output parameters to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: call multiply(:value, :result))

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ### Update `` Updates data in a database. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Transactional Action

Enumeration, one of:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE

  • NOT_SUPPORTED

The type of joining action that operations can take regarding transactions.

JOIN_IF_POSSIBLE

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

SQL Query Text

String

The text of the SQL query to execute

x

Parameter Types

Allows to optionally specify the type of one or more of the parameters in the query. If provided, you’re not even required to reference all of the parameters, but you cannot reference a parameter not present in the input values

Input Parameters

Object

A Map which keys are the name of an input parameter to be set on the JDBC prepared statement. Each parameter should be referenced in the sql text using a semicolon prefix (E.g: where ID = :myParamName)). The map’s values will contain the actual assignation for each parameter.

Auto Generate Keys

Boolean

Indicates when to make auto-generated keys available for retrieval.

false

Auto Generated Keys Column Indexes

Array of Number

List of column indexes that indicates which auto-generated keys to make available for retrieval.

Auto Generated Keys Column Names

Array of String

List of column names that indicates which auto-generated keys should be made available for retrieval.

Target Variable

String

Name of the variable that storesoperation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Statement Result

### For Configurations - [Config](#config) #### Throws - DB:QUERY\_EXECUTION - DB:CONNECTIVITY - DB:RETRY\_EXHAUSTED - DB:BAD\_SQL\_SYNTAX ## Sources ### On Table Row `` Selects from a table at a regular interval and generates one message per each obtained row. Optionally, watermark and ID columns can be provided. If a watermark column is provided, the values taken from that column will be used to filter the contents of the next poll, so that only rows with a greater watermark value are returned. If an ID column is provided, this component will automatically make sure that the same row is not picked twice by concurrent polls #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Table

String

The name of the table to select from

x

Watermark Column

String

The name of the column to use for watermark. Values taken from this column will be used to filter the contents of the next poll, so that only rows with a greater watermark value are processed.

Id Column

String

The name of the column to consider as row ID. If provided, this component will make sure that the same row is not processed twice by concurrent polls.

Transactional Action

Enumeration, one of:

  • ALWAYS_BEGIN

  • NONE

The type of beginning action that sources can take regarding transactions.

NONE

Transaction Type

Enumeration, one of:

  • LOCAL

  • XA

The type of transaction to create. Availability depends on Mule version.

LOCAL

Primary Node Only

Boolean

Determines whether to execute this source on only the primary node when running Mule instances in a cluster. When deployed in a clustered environment with multiple workers, this must be enabled to prevent duplicate record processing.

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling.

x

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Query Timeout

Number

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. No timeout is used by default.

0

Query Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A TimeUnit which qualifies the #queryTimeout

SECONDS

Use Column Numbers

Boolean

When true, uses column numbers (1, 2, 3..) instead of column names as keys in the result metadata. This is useful when the query returns duplicate column names, which would otherwise cause a metadata error.

false

Fetch Size

Number

Indicates how many rows to fetch from the database when rows are read from a resultSet. This property is required when streaming is true; in that case a default value (10) is used.

Max Rows

Number

Sets the limit for the maximum number of rows that any ResultSet object generated by this message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Object

### For Configurations - [Config](#config) ## Types ### Pooling Profile
FieldTypeDescriptionDefault ValueRequired

Max Pool Size

Number

Maximum number of connections a pool maintains at any given time.

5

Min Pool Size

Number

Minimum number of connections a pool maintains at any given time.

0

Acquire Increment

Number

Determines how many connections at a time to try to acquire when the pool is exhausted.

1

Prepared Statement Cache Size

Number

Determines how many statements are cached per pooled connection.

5

Max Wait

Number

The amount of time a client calling getConnection() waits for a connection to be checked-in or acquired when the pool is exhausted. A value of 0 means wait indefinitely.

0

Max Wait Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the Max Wait.

SECONDS

Max Idle Time

Number

The number of seconds that a connection can remain pooled but unused before being discarded. A value of 0 means idle connections never expire.

0

Max Statements

Number

Deprecated. Always set to 0.

0

Test Connection On Checkout

Boolean

If true, an operation is performed at every connection checkout to verify that the connection is valid.

true

Additional Properties

Object

Specifies additional properties for the data source connection pool.

### Column Type
FieldTypeDescriptionDefault ValueRequired

Id

Number

x

Type Name

String

x

Class Name

String

### Reconnection Configures a reconnection strategy for an operation.
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Reconnection Strategy

Reconnection strategy to use.

### Reconnect
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often to attempt to reconnect, in milliseconds.

Count

Number

How many reconnection attempts the Mule app can make.

### Reconnect Forever
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often to attempt to reconnect, in milliseconds.

### TLS Configures TLS to provide secure communications for the Mule app.
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

Comma-separated list of protocols enabled for this context.

Enabled Cipher Suites

String

Comma-separated list of cipher suites enabled for this context.

Trust Store

Configures the TLS truststore.

Key Store

Configures the TLS keystore.

Revocation Check

### Truststore Configures the truststore for TLS.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the truststore. Mule resolves the path relative to the current classpath and file system.

Password

String

Password used to protect the truststore.

Type

String

Type of store.

Algorithm

String

Encryption algorithm that the truststore uses.

Insecure

Boolean

If true, Mule stops performing certificate validations. Setting this to true can make connections vulnerable to attacks.

### Keystore Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the keystore. Mule resolves the path relative to the current classpath and file system.

Type

String

Type of store.

Alias

String

Alias of the key to use when the keystore contains multiple private keys. By default, Mule uses the first key in the file.

Key Password

String

Password used to protect the private key.

Password

String

Password used to protect the keystore.

Algorithm

String

Encryption algorithm that the keystore uses.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Which elements to verify in the certificate chain:

  • true

Verify only the last element in the certificate chain.

  • false

Verify all elements in the certificate chain.

Prefer Crls

Boolean

How to check certificate validity:

  • true

Check the Certification Revocation List (CRL) for certificate validity.

  • false

Use the Online Certificate Status Protocol (OCSP) to check certificate validity.

No Fallback

Boolean

Whether to use the secondary method to check certificate validity:

  • true

Use the method that wasn’t specified in the Prefer Crls field (the secondary method) to check certificate validity.

  • false

Do not use the secondary method to check certificate validity.

Soft Fail

Boolean

What to do if the revocation server can’t be reached or is busy:

  • true

Avoid verification failure.

  • false

Allow the verification to fail.

### Custom OCSP Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

URL of the OCSP responder.

Cert Alias

String

Alias of the signing certificate for the OCSP response. If specified, the alias must be in the truststore.

### CRL File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the CRL file.

### Expiration Policy Configures an expiration policy strategy.
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

Configures the maximum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Time unit for the Max Idle Time field.

### Redelivery Policy Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

Maximum number of times that a redelivered request can be processed unsuccessfully before returning a REDELIVERY_EXHAUSTED error.

Use Secure Hash

Boolean

If true, Mule uses a secure hash algorithm to identify a redelivered message.

Message Digest Algorithm

String

Secure hashing algorithm to use if the Use Secure Hash field is true. If the payload of the message is a Java object, Mule ignores this value and returns the value that the payload’s hashCode() returned.

Id Expression

String

One or more expressions that determine when a message was redelivered. You can set this property only if the Use Secure Hash field is false.

Object Store

Object Store

Configures the object store that stores the redelivery counter for each message.

### Parameter Type
FieldTypeDescriptionDefault ValueRequired

Key

String

The name of the input parameter.

x

Type Classifier

x

### Type Classifier
FieldTypeDescriptionDefault ValueRequired

Type

Enumeration, one of:

  • BIT

  • TINYINT

  • SMALLINT

  • INTEGER

  • BIGINT

  • FLOAT

  • REAL

  • DOUBLE

  • NUMERIC

  • DECIMAL

  • CHAR

  • VARCHAR

  • LONGVARCHAR

  • DATE

  • TIME

  • TIMESTAMP

  • BINARY

  • VARBINARY

  • LONGVARBINARY

  • NULL

  • OTHER

  • JAVA_OBJECT

  • DISTINCT

  • STRUCT

  • ARRAY

  • BLOB

  • CLOB

  • REF

  • DATALINK

  • BOOLEAN

  • ROWID

  • NCHAR

  • NVARCHAR

  • LONGNVARCHAR

  • NCLOB

  • SQLXML

  • REF_CURSOR

  • UNKNOWN

Custom Type

String

### Statement Result
FieldTypeDescriptionDefault ValueRequired

Affected Rows

Number

Generated Keys

Object

### Repeatable In Memory Iterable
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

The amount of instances that is initially be allowed to be kept in memory to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then the buffer expands according to the bufferSizeIncrement attribute, with an upper limit of maxInMemorySize. Default value is 100 instances.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full. Default value is 100 instances.

Max Buffer Size

Number

Maximum size of the buffer. If the buffer size exceeds this value, Mule raises a STREAM_MAXIMUM_SIZE_EXCEEDED error. A value of less than or equal to 0 means no limit.

### Repeatable File Store Iterable
FieldTypeDescriptionDefault ValueRequired

In Memory Objects

Number

The maximum amount of instances to keep in memory. If more than that is required, content on the disk is buffered.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the In Memory Size field.

### Repeatable In Memory Stream Configures the in-memory streaming strategy by which the request fails if the data exceeds the MAX buffer size. Always run performance tests to find the optimal buffer size for your specific use case.
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

Initial amount of memory to allocate to the data stream. If the streamed data exceeds this value, the buffer expands by Buffer Size Increment, with an upper limit of Max In Memory Size value.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full.

Max Buffer Size

Number

Maximum size of the buffer. If the buffer size exceeds this value, Mule raises a STREAM_MAXIMUM_SIZE_EXCEEDED error. A value of less than or equal to 0 means no limit.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the Initial Buffer Size, Buffer Size Increment, and Buffer Unit fields.

### Repeatable File Store Stream Configures the repeatable file-store streaming strategy by which Mule keeps a portion of the stream content in memory. If the stream content is larger than the configured buffer size, Mule backs up the buffer’s content to disk and then clears the memory.
FieldTypeDescriptionDefault ValueRequired

In Memory Size

Number

Maximum amount of memory that the stream can use for data. If the amount of memory exceeds this value, Mule buffers the content to disk. To optimize performance:

  • Configure a larger buffer size to avoid the number of times Mule needs to write the buffer on disk. This increases performance, but it also limits the number of concurrent requests your application can process, because it requires additional memory.

  • Configure a smaller buffer size to decrease memory load at the expense of response time.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the In Memory Size field.

### Output Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

The name of the input parameter.

x

Type Classifier

x

--- product: Database Connector version: 1.14 --- # Database Connector XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-db-connector x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `database`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## Next Step After completing your namespace and `pom.xml` file, you can try the [Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Database Connector XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-db-connector x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `database`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## Next Step After completing your namespace and `pom.xml` file, you can try the [Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Database Connector XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-db-connector x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `database`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## Next Step After completing your namespace and `pom.xml` file, you can try the [Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Execute a Script Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Execute script** operation executes a SQL script of random length as a single database statement. The operation frequently creates schemas and tables, inserts data, and performs data rotation. Data rotation is performed by nightly jobs that move and archive data into historic tables and purge online tables. Some points to consider: - The script can contain multiple statements. - Statements can be of different types. - No input or output parameters are accepted. - The operation runs any script that does not involve a SQL projection. You can use the **Execute script** operation either by embedding the script in the operation or by referencing the script from a file, but you cannot use both ways of executing a script simultaneously. Executing a script returns an array of integers, one element per executed statement. Each integer represents the number of objects affected by the statement. The **Execute script** and **Bulk** operations are intended for different uses. For example, although you can build a script that inserts many rows into the database, you could not conveniently provide dynamic parameters to the script. Also, ensure that the script protects against a SQL injection attack. The following examples illustrate how to configure the **Execute script** operation embedding the script in the operation, and how to reference the script from a file. ## Configure the Execute Script Operation Embedding the Script To configure the operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Execute script** operation. 2. Drag the **Execute script** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query script to execute: ```xml update PLANET set NAME='Mercury' where POSITION=0; update PLANET set NAME='Mercury' where POSITION=4`. ``` The following screenshot shows the configuration in Studio: ![The Execute script operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-execute-script-1.png) Figure 1. Execute script operation configuration In the XML editor, the `` configuration looks like this: ```xml update PLANET set NAME='Mercury' where POSITION=0; update PLANET set NAME='Mercury' where POSITION=4 ``` ## Configure the Execute Script Operation Referencing the Script To configure the operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Execute script** operation. 2. Drag the **Execute script** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **Script Path** field to the location of the script file to load, for example, `integration/executescript/bulk-script.sql`. The file can point to a resource on the class path or on a disk. The following screenshot shows the configuration in Studio: ![The Execute script operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-execute-script-2.png) Figure 2. Execute Script operation configuration In the XML editor, the `` and `file` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Execute a Script Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Execute script** operation executes a SQL script of random length as a single database statement. The operation frequently creates schemas and tables, inserts data, and performs data rotation. Data rotation is performed by nightly jobs that move and archive data into historic tables and purge online tables. Some points to consider: - The script can contain multiple statements. - Statements can be of different types. - No input or output parameters are accepted. - The operation runs any script that does not involve a SQL projection. You can use the **Execute script** operation either by embedding the script in the operation or by referencing the script from a file, but you cannot use both ways of executing a script simultaneously. Executing a script returns an array of integers, one element per executed statement. Each integer represents the number of objects affected by the statement. The **Execute script** and **Bulk** operations are intended for different uses. For example, although you can build a script that inserts many rows into the database, you could not conveniently provide dynamic parameters to the script. Also, ensure that the script protects against a SQL injection attack. The following examples illustrate how to configure the **Execute script** operation embedding the script in the operation, and how to reference the script from a file. ## Configure the Execute Script Operation Embedding the Script To configure the operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Execute script** operation. 2. Drag the **Execute script** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query script to execute: ```xml update PLANET set NAME='Mercury' where POSITION=0; update PLANET set NAME='Mercury' where POSITION=4`. ``` The following screenshot shows the configuration in Studio: ![The Execute script operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-execute-script-1.png) Figure 1. Execute script operation configuration In the XML editor, the `` configuration looks like this: ```xml update PLANET set NAME='Mercury' where POSITION=0; update PLANET set NAME='Mercury' where POSITION=4 ``` ## Configure the Execute Script Operation Referencing the Script To configure the operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Execute script** operation. 2. Drag the **Execute script** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **Script Path** field to the location of the script file to load, for example, `integration/executescript/bulk-script.sql`. The file can point to a resource on the class path or on a disk. The following screenshot shows the configuration in Studio: ![The Execute script operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-execute-script-2.png) Figure 2. Execute Script operation configuration In the XML editor, the `` and `file` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Execute a Script Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Execute script** operation executes a SQL script of random length as a single database statement. The operation frequently creates schemas and tables, inserts data, and performs data rotation. Data rotation is performed by nightly jobs that move and archive data into historic tables and purge online tables. Some points to consider: - The script can contain multiple statements. - Statements can be of different types. - No input or output parameters are accepted. - The operation runs any script that does not involve a SQL projection. You can use the **Execute script** operation either by embedding the script in the operation or by referencing the script from a file, but you cannot use both ways of executing a script simultaneously. Executing a script returns an array of integers, one element per executed statement. Each integer represents the number of objects affected by the statement. The **Execute script** and **Bulk** operations are intended for different uses. For example, although you can build a script that inserts many rows into the database, you could not conveniently provide dynamic parameters to the script. Also, ensure that the script protects against a SQL injection attack. The following examples illustrate how to configure the **Execute script** operation embedding the script in the operation, and how to reference the script from a file. ## Configure the Execute Script Operation Embedding the Script To configure the operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Execute script** operation. 2. Drag the **Execute script** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query script to execute: ```xml update PLANET set NAME='Mercury' where POSITION=0; update PLANET set NAME='Mercury' where POSITION=4`. ``` The following screenshot shows the configuration in Studio: ![The Execute script operation configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-execute-script-1.png) Figure 1. Execute script operation configuration In the XML editor, the `` configuration looks like this: ```xml update PLANET set NAME='Mercury' where POSITION=0; update PLANET set NAME='Mercury' where POSITION=4 ``` ## Configure the Execute Script Operation Referencing the Script To configure the operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Execute script** operation. 2. Drag the **Execute script** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **Script Path** field to the location of the script file to load, for example, `integration/executescript/bulk-script.sql`. The file can point to a resource on the class path or on a disk. The following screenshot shows the configuration in Studio: ![The Execute script operation configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-execute-script-2.png) Figure 2. Execute Script operation configuration In the XML editor, the `` and `file` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Execute Bulk Operations Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) supports the **Bulk insert**, **Bulk update**, and **Bulk delete** operations that enable you to manage data in bulk. This improves the performance compared to executing a single insert, update, or delete operation at various times. These operations are similar to their single counterparts, except that instead of receiving input parameters as key-value pairs, the bulk operations expect a list of key-value pairs. Avoid unnecessary steps by doing a bulk operation: - Parse the query only once - Require only one database connection since a single statement is executed - Minimize network overhead - RDBMS can execute the bulk operation While some statements in the bulk operation can be successfully executed, some can result in an error (for example, if the **Bulk insert** operation fails to insert 1 out of 100 rows, a single exception is thrown describing what went wrong). It will be up to the driver to either stop the execution immediately and ignore all the remaining operations, or continue to execute the remaining statements. In both cases, whenever an error occurs, examine the Mule app logs that provide details on what caused the failure. The following example shows how to configure the operations in a Mule application that inserts, updates, and deletes customers and products data into a MySQL database. To accomplish this example, you must: - Run an SQL statement that creates two tables called `CUSTOMERS` and `PRODUCTS`. - Configure the SQL database connection. - Create the Mule app. - Run the application and then test it by using with curl commands. ![Bulk insert](/mulesoft/current/en-us/db-connector/1.14/_images/database-bulkoperations-flow.png) ## Create the Table in the Database Before configuring the SQL database connection and creating the Mule app, run the following SQL statement to create the tables called `CUSTOMERS` and `PRODUCTS` and insert 4 products into the table `PRODUCTS`: ```sql CREATE DATABASE DEMO; USE DEMO; CREATE TABLE CUSTOMERS ( ID bigint AUTO_INCREMENT PRIMARY KEY, NAME varchar(30) NOT NULL, LAST_NAME varchar(30) NOT NULL ); CREATE TABLE PRODUCTS ( ID bigint AUTO_INCREMENT PRIMARY KEY, PRICE numeric(8, 2) NOT NULL, ITEM varchar(30) NOT NULL ); INSERT INTO PRODUCTS (PRICE, ITEM) values (50.0, 'shampoo'); INSERT INTO PRODUCTS (PRICE, ITEM) values (150.5, 'olive oil'); INSERT INTO PRODUCTS (PRICE, ITEM) values (11, 'coconut oil'); INSERT INTO PRODUCTS (PRICE, ITEM) values (133, 'wine'); ``` ## Configure a MySQL Database Connection After you create the table, go to Anypoint Studio to configure the MySQL database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, complete the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set **Name** to `dbConfig`. 10. In the **Connection** field, select **MySQL Connection**. 11. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. In the **Connection** section, complete the following fields: - **Host**: `localhost` - **Port**: `3306` - **User**: `root` - **Password**: `mulesoft` - **Database**: `demo` 13. Click **Test Connection** to confirm that Mule can connect to the database. 14. Click **OK**. ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-1.png) The following screenshot shows the Database global element configuration: ![The database general configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/1.14/_images/database-bulk-example-2.png) ## Create the First Flow The first flow inserts in bulk the customers' items into the `CUSTOMERS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `/insert`. 4. Drag a **Bulk insert** operation to the right of the **Listener** source. 5. For **Connector configuration**, select `Database_Config`. 6. In **Input Parameters**, add the following expression: `[{'id': 2, 'name': 'George', 'lastName': 'Costanza'}, {'id': 3, 'name': 'Cosmo', 'lastName': 'Kramer'}]` 7. In **SQL Query text**, add the following: `INSERT INTO CUSTOMERS (NAME, LAST_NAME) values (:name, :lastName)` ## Create the Second Flow The second flow updates in bulk the price of the products in the `PRODUCTS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it below the first flow. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `update`. 4. Drag a **Set Payload** component to the right of the **Listener** source. 5. In **Value** add the following expression: ```text [{ discountRate: 0.1, price: 50 }, { discountRate: 0.2, price: 150.5 }] ``` 6. Drag a **Bulk update** operation to the right of the **Set Payload** component. 7. For **Connector configuration**, select `Database_Config`. 8. In **SQL Query text**, add the following expression: `UPDATE PRODUCTS SET PRICE = PRICE * :discountRate WHERE PRICE = :price` ## Create the Third Flow The third flow deletes in bulk products from the `PRODUCTS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it below the first flow. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `/delete`. 4. Drag a **Set Payload** component to the right of the **Listener** source. 5. In **Value** add the following expression: ```text [{ price: 11 }, { price: 133 }] ``` 6. Drag a **Bulk delete** operation to the right of the **Set Payload** component. 7. For **Connector configuration**, select `Database_Config`. 8. In **SQL Query text**, add the following expression: `DELETE FROM PRODUCTS WHERE PRICE = :price` ## Run and Test the Mule App To run and test the Mule app: 1. Save the project in Studio. 2. Click **Run > Run** to deploy the app. 3. In your internet browser, test the app by running the following CURL commands: `curl [http://localhost:8081/insert](http://localhost:8081/insert)` `curl [http://localhost:8081/update](http://localhost:8081/update)` `curl [http://localhost:8081/delete](http://localhost:8081/delete)` ## XML for Mule App Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) --- product: Database Connector version: 1.15 --- # Execute Bulk Operations Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) supports the **Bulk insert**, **Bulk update**, and **Bulk delete** operations that enable you to manage data in bulk. This improves the performance compared to executing a single insert, update, or delete operation at various times. These operations are similar to their single counterparts, except that instead of receiving input parameters as key-value pairs, the bulk operations expect a list of key-value pairs. Avoid unnecessary steps by doing a bulk operation: - Parse the query only once - Require only one database connection since a single statement is executed - Minimize network overhead - RDBMS can execute the bulk operation While some statements in the bulk operation can be successfully executed, some can result in an error (for example, if the **Bulk insert** operation fails to insert 1 out of 100 rows, a single exception is thrown describing what went wrong). It will be up to the driver to either stop the execution immediately and ignore all the remaining operations, or continue to execute the remaining statements. In both cases, whenever an error occurs, examine the Mule app logs that provide details on what caused the failure. ## Type Coercion Behavior Database Connector performs type coercion to construct proper JDBC parameter types. The validation point depends on Java type conversion strictness—strict conversions (String to BigDecimal) are validated at the connector level, while lenient conversions (String to Integer) may pass through to the database for validation. Database drivers handle validation differently, which affects when validation occurs and whether partial data might be committed. These sections describe the two validation types: - Connector-Level Validation When the connector performs strict type conversion, validation occurs before data is sent to the database: - DECIMAL/NUMERIC: Non-numeric strings cannot be converted to BigDecimal - DATE/TIMESTAMP: Invalid date formats cannot be parsed Result: Zero records are committed because validation occurs before the database operation runs. - Database-Level Validation When the connector performs lenient type conversion or no conversion is required, database drivers accept the data and validate it when the operation executes: - INTEGER: Lenient conversion allows invalid values to pass through to the database - VARCHAR: No conversion required, so values pass through as-is - Constraint violations: Always validated at the database level Result: Records processed before validation issues are detected may be committed depending on how the database driver handles validation. Some drivers continue processing after a validation issue (partial success), while others stop on the first validation issue (all records rejected). - Preventing Partial Commits To prevent partial commits across all database platforms, wrap bulk operations in a transactional scope. This approach manages transactions at the Mule flow level and handles both connector-side validation issues (catches exceptions before database interaction) and database-side validation issues (rolls back partial commits). For example, use a Try scope with `transactionalAction="ALWAYS_BEGIN"` or `"BEGIN_OR_JOIN"`. ## Execute Bulk Operations Examples This example shows how to configure the operations in a Mule application that inserts, updates, and deletes customers and products data into a MySQL database. To accomplish this example, you must: - Run an SQL statement that creates two tables called `CUSTOMERS` and `PRODUCTS`. - Configure the SQL database connection. - Create the Mule app. - Run the application and then test it by using with curl commands. ![Bulk insert](/mulesoft/current/en-us/db-connector/1.15/_images/database-bulkoperations-flow.png) ## Create the Table in the Database Before configuring the SQL database connection and creating the Mule app, run the following SQL statement to create the tables called `CUSTOMERS` and `PRODUCTS` and insert 4 products into the table `PRODUCTS`: ```sql CREATE DATABASE DEMO; USE DEMO; CREATE TABLE CUSTOMERS ( ID bigint AUTO_INCREMENT PRIMARY KEY, NAME varchar(30) NOT NULL, LAST_NAME varchar(30) NOT NULL ); CREATE TABLE PRODUCTS ( ID bigint AUTO_INCREMENT PRIMARY KEY, PRICE numeric(8, 2) NOT NULL, ITEM varchar(30) NOT NULL ); INSERT INTO PRODUCTS (PRICE, ITEM) values (50.0, 'shampoo'); INSERT INTO PRODUCTS (PRICE, ITEM) values (150.5, 'olive oil'); INSERT INTO PRODUCTS (PRICE, ITEM) values (11, 'coconut oil'); INSERT INTO PRODUCTS (PRICE, ITEM) values (133, 'wine'); ``` ## Configure a MySQL Database Connection After you create the table, go to Anypoint Studio to configure the MySQL database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, complete the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set **Name** to `dbConfig`. 10. In the **Connection** field, select **MySQL Connection**. 11. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. In the **Connection** section, complete the following fields: - **Host**: `localhost` - **Port**: `3306` - **User**: `root` - **Password**: `mulesoft` - **Database**: `demo` 13. Click **Test Connection** to confirm that Mule can connect to the database. 14. Click **OK**. ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-1.png) The following screenshot shows the Database global element configuration: ![The database general configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/1.15/_images/database-bulk-example-2.png) ## Create the First Flow The first flow inserts in bulk the customers' items into the `CUSTOMERS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `/insert`. 4. Drag a **Bulk insert** operation to the right of the **Listener** source. 5. For **Connector configuration**, select `Database_Config`. 6. In **Input Parameters**, add the following expression: `[{'id': 2, 'name': 'George', 'lastName': 'Costanza'}, {'id': 3, 'name': 'Cosmo', 'lastName': 'Kramer'}]` 7. In **SQL Query text**, add the following: `INSERT INTO CUSTOMERS (NAME, LAST_NAME) values (:name, :lastName)` ## Create the Second Flow The second flow updates in bulk the price of the products in the `PRODUCTS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it below the first flow. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `update`. 4. Drag a **Set Payload** component to the right of the **Listener** source. 5. In **Value** add the following expression: ```text [{ discountRate: 0.1, price: 50 }, { discountRate: 0.2, price: 150.5 }] ``` 6. Drag a **Bulk update** operation to the right of the **Set Payload** component. 7. For **Connector configuration**, select `Database_Config`. 8. In **SQL Query text**, add the following expression: `UPDATE PRODUCTS SET PRICE = PRICE * :discountRate WHERE PRICE = :price` ## Create the Third Flow The third flow deletes in bulk products from the `PRODUCTS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it below the first flow. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `/delete`. 4. Drag a **Set Payload** component to the right of the **Listener** source. 5. In **Value** add the following expression: ```text [{ price: 11 }, { price: 133 }] ``` 6. Drag a **Bulk delete** operation to the right of the **Set Payload** component. 7. For **Connector configuration**, select `Database_Config`. 8. In **SQL Query text**, add the following expression: `DELETE FROM PRODUCTS WHERE PRICE = :price` ## Run and Test the Mule App To run and test the Mule app: 1. Save the project in Studio. 2. Click **Run > Run** to deploy the app. 3. In your internet browser, test the app by running the following CURL commands: `curl [http://localhost:8081/insert](http://localhost:8081/insert)` `curl [http://localhost:8081/update](http://localhost:8081/update)` `curl [http://localhost:8081/delete](http://localhost:8081/delete)` ## XML for Mule App Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) --- product: Database Connector version: 1.16 is-latest-version: true --- # Execute Bulk Operations Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) supports the **Bulk insert**, **Bulk update**, and **Bulk delete** operations that enable you to manage data in bulk. This improves the performance compared to executing a single insert, update, or delete operation at various times. These operations are similar to their single counterparts, except that instead of receiving input parameters as key-value pairs, the bulk operations expect a list of key-value pairs. Avoid unnecessary steps by doing a bulk operation: - Parse the query only once - Require only one database connection since a single statement is executed - Minimize network overhead - RDBMS can execute the bulk operation While some statements in the bulk operation can be successfully executed, some can result in an error (for example, if the **Bulk insert** operation fails to insert 1 out of 100 rows, a single exception is thrown describing what went wrong). It will be up to the driver to either stop the execution immediately and ignore all the remaining operations, or continue to execute the remaining statements. In both cases, whenever an error occurs, examine the Mule app logs that provide details on what caused the failure. ## Type Coercion Behavior Database Connector performs type coercion to construct proper JDBC parameter types. The validation point depends on Java type conversion strictness—strict conversions (String to BigDecimal) are validated at the connector level, while lenient conversions (String to Integer) may pass through to the database for validation. Database drivers handle validation differently, which affects when validation occurs and whether partial data might be committed. These sections describe the two validation types: - Connector-Level Validation When the connector performs strict type conversion, validation occurs before data is sent to the database: - DECIMAL/NUMERIC: Non-numeric strings cannot be converted to BigDecimal - DATE/TIMESTAMP: Invalid date formats cannot be parsed Result: Zero records are committed because validation occurs before the database operation runs. - Database-Level Validation When the connector performs lenient type conversion or no conversion is required, database drivers accept the data and validate it when the operation executes: - INTEGER: Lenient conversion allows invalid values to pass through to the database - VARCHAR: No conversion required, so values pass through as-is - Constraint violations: Always validated at the database level Result: Records processed before validation issues are detected may be committed depending on how the database driver handles validation. Some drivers continue processing after a validation issue (partial success), while others stop on the first validation issue (all records rejected). - Preventing Partial Commits To prevent partial commits across all database platforms, wrap bulk operations in a transactional scope. This approach manages transactions at the Mule flow level and handles both connector-side validation issues (catches exceptions before database interaction) and database-side validation issues (rolls back partial commits). For example, use a Try scope with `transactionalAction="ALWAYS_BEGIN"` or `"BEGIN_OR_JOIN"`. ## Execute Bulk Operations Examples This example shows how to configure the operations in a Mule application that inserts, updates, and deletes customers and products data into a MySQL database. To accomplish this example, you must: - Run an SQL statement that creates two tables called `CUSTOMERS` and `PRODUCTS`. - Configure the SQL database connection. - Create the Mule app. - Run the application and then test it by using with curl commands. ![Bulk insert](/mulesoft/current/en-us/db-connector/latest/_images/database-bulkoperations-flow.png) ## Create the Table in the Database Before configuring the SQL database connection and creating the Mule app, run the following SQL statement to create the tables called `CUSTOMERS` and `PRODUCTS` and insert 4 products into the table `PRODUCTS`: ```sql CREATE DATABASE DEMO; USE DEMO; CREATE TABLE CUSTOMERS ( ID bigint AUTO_INCREMENT PRIMARY KEY, NAME varchar(30) NOT NULL, LAST_NAME varchar(30) NOT NULL ); CREATE TABLE PRODUCTS ( ID bigint AUTO_INCREMENT PRIMARY KEY, PRICE numeric(8, 2) NOT NULL, ITEM varchar(30) NOT NULL ); INSERT INTO PRODUCTS (PRICE, ITEM) values (50.0, 'shampoo'); INSERT INTO PRODUCTS (PRICE, ITEM) values (150.5, 'olive oil'); INSERT INTO PRODUCTS (PRICE, ITEM) values (11, 'coconut oil'); INSERT INTO PRODUCTS (PRICE, ITEM) values (133, 'wine'); ``` ## Configure a MySQL Database Connection After you create the table, go to Anypoint Studio to configure the MySQL database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, complete the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set **Name** to `dbConfig`. 10. In the **Connection** field, select **MySQL Connection**. 11. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. In the **Connection** section, complete the following fields: - **Host**: `localhost` - **Port**: `3306` - **User**: `root` - **Password**: `mulesoft` - **Database**: `demo` 13. Click **Test Connection** to confirm that Mule can connect to the database. 14. Click **OK**. ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-1.png) The following screenshot shows the Database global element configuration: ![The database general configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/latest/_images/database-bulk-example-2.png) ## Create the First Flow The first flow inserts in bulk the customers' items into the `CUSTOMERS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `/insert`. 4. Drag a **Bulk insert** operation to the right of the **Listener** source. 5. For **Connector configuration**, select `Database_Config`. 6. In **Input Parameters**, add the following expression: `[{'id': 2, 'name': 'George', 'lastName': 'Costanza'}, {'id': 3, 'name': 'Cosmo', 'lastName': 'Kramer'}]` 7. In **SQL Query text**, add the following: `INSERT INTO CUSTOMERS (NAME, LAST_NAME) values (:name, :lastName)` ## Create the Second Flow The second flow updates in bulk the price of the products in the `PRODUCTS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it below the first flow. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `update`. 4. Drag a **Set Payload** component to the right of the **Listener** source. 5. In **Value** add the following expression: ```text [{ discountRate: 0.1, price: 50 }, { discountRate: 0.2, price: 150.5 }] ``` 6. Drag a **Bulk update** operation to the right of the **Set Payload** component. 7. For **Connector configuration**, select `Database_Config`. 8. In **SQL Query text**, add the following expression: `UPDATE PRODUCTS SET PRICE = PRICE * :discountRate WHERE PRICE = :price` ## Create the Third Flow The third flow deletes in bulk products from the `PRODUCTS` table, follow these steps to create the flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it below the first flow. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set **Path** to `/delete`. 4. Drag a **Set Payload** component to the right of the **Listener** source. 5. In **Value** add the following expression: ```text [{ price: 11 }, { price: 133 }] ``` 6. Drag a **Bulk delete** operation to the right of the **Set Payload** component. 7. For **Connector configuration**, select `Database_Config`. 8. In **SQL Query text**, add the following expression: `DELETE FROM PRODUCTS WHERE PRICE = :price` ## Run and Test the Mule App To run and test the Mule app: 1. Save the project in Studio. 2. Click **Run > Run** to deploy the app. 3. In your internet browser, test the app by running the following CURL commands: `curl [http://localhost:8081/insert](http://localhost:8081/insert)` `curl [http://localhost:8081/update](http://localhost:8081/update)` `curl [http://localhost:8081/delete](http://localhost:8081/delete)` ## XML for Mule App Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) --- product: Database Connector version: 1.14 --- # Execute DDL Statements Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Execute DDL** operation enables to execute DDL queries against a database. Data Definition Language (DDL) statements, are special types of SQL statements that do not directly access or modify data. Instead, they create, modify, or destroy data structures, stored procedures, and so on. You can also use DDL statements to create or modify data within tables or other data structures. ## Configure the Execute DDL Operation in Studio The following example shows how to configure the **Execute DDL** operation that creates a new table named `electronic` with columns named `id`, `name`, `description`, `price`, and `discount`: 1. In the **Mule Palette** view, search for `database` and select the **Execute DDL** operation. 2. Drag the **Execute DDL** operation onto the Studio canvas. The operation creates a table and returns `0` unless there is an error. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query to execute, for example: ```xml CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ``` The following screenshot shows the configuration in Studio: ![The Execute DDL operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-executeddl.png) Figure 1. Execute DDL configuration In the XML editor, the `` configuration looks like this: ```xml CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ) ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Execute DDL Statements Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Execute DDL** operation enables to execute DDL queries against a database. Data Definition Language (DDL) statements, are special types of SQL statements that do not directly access or modify data. Instead, they create, modify, or destroy data structures, stored procedures, and so on. You can also use DDL statements to create or modify data within tables or other data structures. ## Configure the Execute DDL Operation in Studio The following example shows how to configure the **Execute DDL** operation that creates a new table named `electronic` with columns named `id`, `name`, `description`, `price`, and `discount`: 1. In the **Mule Palette** view, search for `database` and select the **Execute DDL** operation. 2. Drag the **Execute DDL** operation onto the Studio canvas. The operation creates a table and returns `0` unless there is an error. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query to execute, for example: ```xml CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ``` The following screenshot shows the configuration in Studio: ![The Execute DDL operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-executeddl.png) Figure 1. Execute DDL configuration In the XML editor, the `` configuration looks like this: ```xml CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ) ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Execute DDL Statements Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Execute DDL** operation enables to execute DDL queries against a database. Data Definition Language (DDL) statements, are special types of SQL statements that do not directly access or modify data. Instead, they create, modify, or destroy data structures, stored procedures, and so on. You can also use DDL statements to create or modify data within tables or other data structures. ## Configure the Execute DDL Operation in Studio The following example shows how to configure the **Execute DDL** operation that creates a new table named `electronic` with columns named `id`, `name`, `description`, `price`, and `discount`: 1. In the **Mule Palette** view, search for `database` and select the **Execute DDL** operation. 2. Drag the **Execute DDL** operation onto the Studio canvas. The operation creates a table and returns `0` unless there is an error. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query to execute, for example: ```xml CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ``` The following screenshot shows the configuration in Studio: ![The Execute DDL operation configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-executeddl.png) Figure 1. Execute DDL configuration In the XML editor, the `` configuration looks like this: ```xml CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ) ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Execute Stored Procedures Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Stored procedure** operation invokes a stored procedure on the database. When the stored procedure returns one or more ResultSet instances, streaming is applied automatically to avoid preemptive consumption of the results, which can lead to performance and memory issues. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. The following examples illustrates callable statements and dates on stored procedures, and how to invoke stored procedures by configuring the **Input parameters**, **Output parameters**, and **In out parameters** fields. ## Callable Statements in Stored Procedures Database Connector supports the use of callable statements with the format: `{ call procedureName(:param1, :param2, …​, :paramN) }` Where `:paramN` matches the `Nth` parameter in the stored procedure declaration. Make sure that no whitespace is between the name of the stored procedure and the first parentheses. Even though all JDBC drivers must comply with the JDBC specification format, some drivers have their own specifications. Check the documentation of your JDBC driver for additional information on how to call the stored procedure. For example, for the Snowflake JDBC driver you must set the callable statement without the curly brackets `{` and `}`: `call procedureName(:param1, :param2, …​, :paramN)` ### Passing Parameters to Stored Procedures When passing parameters to a stored procedure: - Place all the parameters the store procedure contains, even optional parameters with default values. - Put the parameters in the same order as they were defined in the stored procedure. - Parameterize the parameters, do not hardcode strings, numbers, etc. The following example illustrates an Oracle database that was initialized when creating a table named `SYSTEM.employees` and stored procedure named `createEmployee`: ```xml CREATE TABLE SYSTEM.employees( employee_id INTEGER GENERATED BY DEFAULT AS IDENTITY, employee_name VARCHAR2(100), employee_age INTEGER, employee_birthday TIMESTAMP, PRIMARY KEY(employee_id) ); CREATE PROCEDURE createEmployee(e_name VARCHAR2, e_age NUMBER, e_birth_date DATE) AS BEGIN INSERT INTO SYSTEM.employees(employee_name, employee_age, employee_birthday) VALUES(e_name, e_age, e_birth_date); END; ``` Because Database Connector does not support named parameters in callable statements, attempting to match parameters by name does not work, for example: `{ call createEmployee(e_age ⇒ :age, e_birth_date ⇒ :date, e_name ⇒ :name) }` You must provide the parameters in the appropriate order, for example: `{ call createEmployee(:name, :age, :date) }`. ## Use Dates on Stored Procedures Database Connector does not support the use of engine-specific embedded functions. For example, if you want to change a date to a specific format before calling a procedure in an Oracle database, the following approach does not work: `{ call createEmployee(e_name ⇒ :name, employee_age ⇒ :age, e_birth_date ⇒ TO_DATE(:date, 'YYYY-MM-DD HH:mm:ss')) }.` Use DataWeave for all data transformations before the invocation to the callable statement. Using the previous example, perform the following transformation: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call createEmployee(:name, :age, :date) }` 3. Set the **Input parameters** field to the following DataWeave code: ```dataweave %dw 2.0 output application/json fun format(d: DateTime) = d as String { format: "yyyy-MM-dd HH:mm:ss" } --- { 'date': format(|2019-10-31T13:00:00.000Z|), 'name': 'rick', 'age': 60 } [source,xml,linenums] ``` The following screenshot shows the configuration in Studio: ![Configuring dates on the Stored procedure operation](/mulesoft/current/en-us/db-connector/1.14/_images/database-stored-example-4.png) Figure 1. Dates on Stored Procedure configuration In the XML editor, the `` with the DataWeave transformation looks like this: ```xml { call createEmployee(:name, :age, :date) } ``` ## Configure the Input Parameters Field in the Stored Procedure Operation In the **Input parameters** field, specify values that create a map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example, `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. When giving values to the parameters: - Define each parameter name with single quotes for example, `'paramName': value`. - For default values either use DataWeave or a variable, so if you pass null, or an empty string the store procedure’s default value won’t be pushed by Mule runtime engine. - Enter input values with parameters only. Do not hardcode the values within the **Stored Procedure** operation. To configure the **Input parameters** field: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call doubleMyInt(:myInt) }` 3. Set the **Input parameters** field to `{'myInt' : payload}`. In the XML editor, the `` and `` configuration looks like this: ```xml { call doubleMyInt(:myInt) } #[{'description' : payload}] ``` ## Configure the In Out Parameters Field in the Stored Procedure Operation In the **In out parameters** field, specify values that create a map in which keys are the name of a parameter to be set on the JDBC prepared statement which is both input and output. Reference each parameter in the SQL text using a colon prefix, for example, `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. To configure the **In out parameters** field: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call doubleMyInt(:myInt) }` 3. Set the **In out parameters** field to `Edit inline`. 4. Click the plus sign (**+**) to add a new value. 5. In the new window, set the **Key** field to `myInt` and the **Value** field to `3`. The following screenshot shows the configuration in Studio: ![The Stored procedure operation with the In out parameters field configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-stored-example-2.png) Figure 2. Stored procedure with In Out parameters configuration In the XML editor, the `` and `` configuration looks like this: ```xml { call doubleMyInt(:myInt) } ``` ## Configure the Input and Output Parameters Fields in the Stored Procedure Operation In the **Output parameters** field, specify a list of values to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example, `call multiply(:value, :result)`. To configure the **Input parameters** and **Output parameters** fields: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call multiplyInts(:int1, :int2, :result1, :int3, :result2) }` 3. Set the **Input parameters** field to: ```xml { 'int1' : 3, 'int2' : 4, 'int3' : 5 } ``` 4. Set the **Output parameters** field to `Edit inline`. 5. Click the plus sign (**+**) to add a new value. 6. In the new window, set the **Key** field to `result1` and the **Type** field to `INTEGER`. 7. Repeat the steps 5 and 6 to add a new value, set the **Key** field to `result2` and the **Type** field to `INTEGER`. The following screenshot shows the configuration in Studio: ![The Stored procedure operation with the Input and Output parameters fields configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-stored-example-3.png) Figure 3. Stored procedure with Input and Output parameters configuration In the XML editor, the `` and `` configuration looks like this: ```xml { call multiplyInts(:int1, :int2, :result1, :int3, :result2) } #[{ 'int1' : 3, 'int2' : 4, 'int3' : 5 }] ``` ## Returning a Result Set When you call a stored procedure that returns a result set, the result set is assigned to the payload by default. To change the returning result set, configure a **Target Variable** or a **Target Value** in the **Advanced** tab of the **Stored procedure** operation configuration. The following example illustrates an MSSQL database that is initialized when creating a table named `languages` and a stored procedure named `myProc` that returns a result set: ```xml CREATE TABLE LANGUAGES (NAME VARCHAR(128), SAMPLE_TEXT VARCHAR(max)); CREATE PROCEDURE myProc AS SELECT * FROM LANGUAGES l; RETURN; ``` 1. In the **Stored procedure** operation configuration screen, set **SQL Query Text** to `{ call myProc() }`. 2. In the **Advanced** tab, set **Target Variable** to `aResult`. ![The Stored procedure operation with the Target Variable field configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-stored-example-5.png) In the XML editor, the `` configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Execute Stored Procedures Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Stored procedure** operation invokes a stored procedure on the database. When the stored procedure returns one or more ResultSet instances, streaming is applied automatically to avoid preemptive consumption of the results, which can lead to performance and memory issues. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. The following examples illustrates callable statements and dates on stored procedures, and how to invoke stored procedures by configuring the **Input parameters**, **Output parameters**, and **In out parameters** fields. ## Callable Statements in Stored Procedures Database Connector supports the use of callable statements with the format: `{ call procedureName(:param1, :param2, …​, :paramN) }` Where `:paramN` matches the `Nth` parameter in the stored procedure declaration. Make sure that no whitespace is between the name of the stored procedure and the first parentheses. Even though all JDBC drivers must comply with the JDBC specification format, some drivers have their own specifications. Check the documentation of your JDBC driver for additional information on how to call the stored procedure. For example, for the Snowflake JDBC driver you must set the callable statement without the curly brackets `{` and `}`: `call procedureName(:param1, :param2, …​, :paramN)` ### Passing Parameters to Stored Procedures When passing parameters to a stored procedure: - Place all the parameters the store procedure contains, even optional parameters with default values. - Put the parameters in the same order as they were defined in the stored procedure. - Parameterize the parameters, do not hardcode strings, numbers, etc. The following example illustrates an Oracle database that was initialized when creating a table named `SYSTEM.employees` and stored procedure named `createEmployee`: ```xml CREATE TABLE SYSTEM.employees( employee_id INTEGER GENERATED BY DEFAULT AS IDENTITY, employee_name VARCHAR2(100), employee_age INTEGER, employee_birthday TIMESTAMP, PRIMARY KEY(employee_id) ); CREATE PROCEDURE createEmployee(e_name VARCHAR2, e_age NUMBER, e_birth_date DATE) AS BEGIN INSERT INTO SYSTEM.employees(employee_name, employee_age, employee_birthday) VALUES(e_name, e_age, e_birth_date); END; ``` Because Database Connector does not support named parameters in callable statements, attempting to match parameters by name does not work, for example: `{ call createEmployee(e_age ⇒ :age, e_birth_date ⇒ :date, e_name ⇒ :name) }` You must provide the parameters in the appropriate order, for example: `{ call createEmployee(:name, :age, :date) }`. ## Use Dates on Stored Procedures Database Connector does not support the use of engine-specific embedded functions. For example, if you want to change a date to a specific format before calling a procedure in an Oracle database, the following approach does not work: `{ call createEmployee(e_name ⇒ :name, employee_age ⇒ :age, e_birth_date ⇒ TO_DATE(:date, 'YYYY-MM-DD HH:mm:ss')) }.` Use DataWeave for all data transformations before the invocation to the callable statement. Using the previous example, perform the following transformation: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call createEmployee(:name, :age, :date) }` 3. Set the **Input parameters** field to the following DataWeave code: ```dataweave %dw 2.0 output application/json fun format(d: DateTime) = d as String { format: "yyyy-MM-dd HH:mm:ss" } --- { 'date': format(|2019-10-31T13:00:00.000Z|), 'name': 'rick', 'age': 60 } [source,xml,linenums] ``` The following screenshot shows the configuration in Studio: ![Configuring dates on the Stored procedure operation](/mulesoft/current/en-us/db-connector/1.15/_images/database-stored-example-4.png) Figure 1. Dates on Stored Procedure configuration In the XML editor, the `` with the DataWeave transformation looks like this: ```xml { call createEmployee(:name, :age, :date) } ``` ## Configure the Input Parameters Field in the Stored Procedure Operation In the **Input parameters** field, specify values that create a map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example, `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. When giving values to the parameters: - Define each parameter name with single quotes for example, `'paramName': value`. - For default values either use DataWeave or a variable, so if you pass null, or an empty string the store procedure’s default value won’t be pushed by Mule runtime engine. - Enter input values with parameters only. Do not hardcode the values within the **Stored Procedure** operation. To configure the **Input parameters** field: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call doubleMyInt(:myInt) }` 3. Set the **Input parameters** field to `{'myInt' : payload}`. In the XML editor, the `` and `` configuration looks like this: ```xml { call doubleMyInt(:myInt) } #[{'description' : payload}] ``` ## Configure the In Out Parameters Field in the Stored Procedure Operation In the **In out parameters** field, specify values that create a map in which keys are the name of a parameter to be set on the JDBC prepared statement which is both input and output. Reference each parameter in the SQL text using a colon prefix, for example, `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. To configure the **In out parameters** field: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call doubleMyInt(:myInt) }` 3. Set the **In out parameters** field to `Edit inline`. 4. Click the plus sign (**+**) to add a new value. 5. In the new window, set the **Key** field to `myInt` and the **Value** field to `3`. The following screenshot shows the configuration in Studio: ![The Stored procedure operation with the In out parameters field configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-stored-example-2.png) Figure 2. Stored procedure with In Out parameters configuration In the XML editor, the `` and `` configuration looks like this: ```xml { call doubleMyInt(:myInt) } ``` ## Configure the Input and Output Parameters Fields in the Stored Procedure Operation In the **Output parameters** field, specify a list of values to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example, `call multiply(:value, :result)`. To configure the **Input parameters** and **Output parameters** fields: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call multiplyInts(:int1, :int2, :result1, :int3, :result2) }` 3. Set the **Input parameters** field to: ```xml { 'int1' : 3, 'int2' : 4, 'int3' : 5 } ``` 4. Set the **Output parameters** field to `Edit inline`. 5. Click the plus sign (**+**) to add a new value. 6. In the new window, set the **Key** field to `result1` and the **Type** field to `INTEGER`. 7. Repeat the steps 5 and 6 to add a new value, set the **Key** field to `result2` and the **Type** field to `INTEGER`. The following screenshot shows the configuration in Studio: ![The Stored procedure operation with the Input and Output parameters fields configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-stored-example-3.png) Figure 3. Stored procedure with Input and Output parameters configuration In the XML editor, the `` and `` configuration looks like this: ```xml { call multiplyInts(:int1, :int2, :result1, :int3, :result2) } #[{ 'int1' : 3, 'int2' : 4, 'int3' : 5 }] ``` ## Returning a Result Set When you call a stored procedure that returns a result set, the result set is assigned to the payload by default. To change the returning result set, configure a **Target Variable** or a **Target Value** in the **Advanced** tab of the **Stored procedure** operation configuration. The following example illustrates an MSSQL database that is initialized when creating a table named `languages` and a stored procedure named `myProc` that returns a result set: ```xml CREATE TABLE LANGUAGES (NAME VARCHAR(128), SAMPLE_TEXT VARCHAR(max)); CREATE PROCEDURE myProc AS SELECT * FROM LANGUAGES l; RETURN; ``` 1. In the **Stored procedure** operation configuration screen, set **SQL Query Text** to `{ call myProc() }`. 2. In the **Advanced** tab, set **Target Variable** to `aResult`. ![The Stored procedure operation with the Target Variable field configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-stored-example-5.png) In the XML editor, the `` configuration looks like this: ```xml ``` ### Calling Stored Procedures with Output Parameters When calling a stored procedure that returns an output parameter, ensure there is no space between the opening curly brace `{` and the return parameter name. The syntax must be `{:returnParameterName = call …​}` without any whitespace. This example illustrates calling a stored procedure with output parameters: ```xml CREATE PROCEDURE dbo.up_NOP_CreateAttachment @NOP_ID INTEGER, @Description VARCHAR(255), @DetailDescription VARCHAR(255), @DetailOriginalFileName VARCHAR(255), @FileExtensionTypeCD VARCHAR(10), @Attachment VARBINARY(MAX) AS BEGIN -- Procedure logic here RETURN @returnCode END ``` To configure the stored procedure operation: 1. In the **Stored procedure** operation configuration screen, set **SQL Query Text** to: `{:returnCode = call dbo.up_NOP_CreateAttachment(:NOP_ID, :Description, :DetailDescription, :DetailOriginalFileName, :FileExtensionTypeCD, :Attachment)}` > [!IMPORTANT] Do not include a space between the opening curly brace `{` and the colon `:` > before the return parameter name. The syntax `{ :returnCode = …​}` with a space causes an > error: "Unable to detect function 'name'". Use `{:returnCode = …​}` without the space. 2. Set the **Input parameters** field to: ```dataweave { 'NOP_ID' : vars.metadataContent.NOPID as Number, 'Description' : vars.metadataContent.Description, 'DetailDescription' : vars.metadataContent.DetailDescription, 'DetailOriginalFileName' : vars.metadataContent.DetailOriginalFileName, 'FileExtensionTypeCD' : vars.metadataContent.FileExtensionTypeCD, 'Attachment' : payload as Binary } ``` 3. Set the **Output parameters** field to `Edit inline`. 4. Click the plus sign (**+**) to add a new value. 5. In the new window, set the **Key** field to `returnCode` and the **Type** field to `INTEGER`. In the XML editor, the `` configuration looks like this: ```xml {:returnCode = call dbo.up_NOP_CreateAttachment(:NOP_ID, :Description, :DetailDescription, :DetailOriginalFileName, :FileExtensionTypeCD, :Attachment)} #[{ 'NOP_ID' : vars.metadataContent.NOPID as Number, 'Description' : vars.metadataContent.Description, 'DetailDescription' : vars.metadataContent.DetailDescription, 'DetailOriginalFileName' : vars.metadataContent.DetailOriginalFileName, 'FileExtensionTypeCD' : vars.metadataContent.FileExtensionTypeCD, 'Attachment' : payload as Binary }] ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Execute Stored Procedures Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Stored procedure** operation invokes a stored procedure on the database. When the stored procedure returns one or more ResultSet instances, streaming is applied automatically to avoid preemptive consumption of the results, which can lead to performance and memory issues. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. The following examples illustrates callable statements and dates on stored procedures, and how to invoke stored procedures by configuring the **Input parameters**, **Output parameters**, and **In out parameters** fields. ## Callable Statements in Stored Procedures Database Connector supports the use of callable statements with the format: `{ call procedureName(:param1, :param2, …​, :paramN) }` Where `:paramN` matches the `Nth` parameter in the stored procedure declaration. Make sure that no whitespace is between the name of the stored procedure and the first parentheses. Even though all JDBC drivers must comply with the JDBC specification format, some drivers have their own specifications. Check the documentation of your JDBC driver for additional information on how to call the stored procedure. For example, for the Snowflake JDBC driver you must set the callable statement without the curly brackets `{` and `}`: `call procedureName(:param1, :param2, …​, :paramN)` ### Passing Parameters to Stored Procedures When passing parameters to a stored procedure: - Place all the parameters the store procedure contains, even optional parameters with default values. - Put the parameters in the same order as they were defined in the stored procedure. - Parameterize the parameters, do not hardcode strings, numbers, etc. The following example illustrates an Oracle database that was initialized when creating a table named `SYSTEM.employees` and stored procedure named `createEmployee`: ```xml CREATE TABLE SYSTEM.employees( employee_id INTEGER GENERATED BY DEFAULT AS IDENTITY, employee_name VARCHAR2(100), employee_age INTEGER, employee_birthday TIMESTAMP, PRIMARY KEY(employee_id) ); CREATE PROCEDURE createEmployee(e_name VARCHAR2, e_age NUMBER, e_birth_date DATE) AS BEGIN INSERT INTO SYSTEM.employees(employee_name, employee_age, employee_birthday) VALUES(e_name, e_age, e_birth_date); END; ``` Because Database Connector does not support named parameters in callable statements, attempting to match parameters by name does not work, for example: `{ call createEmployee(e_age ⇒ :age, e_birth_date ⇒ :date, e_name ⇒ :name) }` You must provide the parameters in the appropriate order, for example: `{ call createEmployee(:name, :age, :date) }`. ## Use Dates on Stored Procedures Database Connector does not support the use of engine-specific embedded functions. For example, if you want to change a date to a specific format before calling a procedure in an Oracle database, the following approach does not work: `{ call createEmployee(e_name ⇒ :name, employee_age ⇒ :age, e_birth_date ⇒ TO_DATE(:date, 'YYYY-MM-DD HH:mm:ss')) }.` Use DataWeave for all data transformations before the invocation to the callable statement. Using the previous example, perform the following transformation: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call createEmployee(:name, :age, :date) }` 3. Set the **Input parameters** field to the following DataWeave code: ```dataweave %dw 2.0 output application/json fun format(d: DateTime) = d as String { format: "yyyy-MM-dd HH:mm:ss" } --- { 'date': format(|2019-10-31T13:00:00.000Z|), 'name': 'rick', 'age': 60 } [source,xml,linenums] ``` The following screenshot shows the configuration in Studio: ![Configuring dates on the Stored procedure operation](/mulesoft/current/en-us/db-connector/latest/_images/database-stored-example-4.png) Figure 1. Dates on Stored Procedure configuration In the XML editor, the `` with the DataWeave transformation looks like this: ```xml { call createEmployee(:name, :age, :date) } ``` ## Configure the Input Parameters Field in the Stored Procedure Operation In the **Input parameters** field, specify values that create a map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example, `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. When giving values to the parameters: - Define each parameter name with single quotes for example, `'paramName': value`. - For default values either use DataWeave or a variable, so if you pass null, or an empty string the store procedure’s default value won’t be pushed by Mule runtime engine. - Enter input values with parameters only. Do not hardcode the values within the **Stored Procedure** operation. To configure the **Input parameters** field: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call doubleMyInt(:myInt) }` 3. Set the **Input parameters** field to `{'myInt' : payload}`. In the XML editor, the `` and `` configuration looks like this: ```xml { call doubleMyInt(:myInt) } #[{'description' : payload}] ``` ## Configure the In Out Parameters Field in the Stored Procedure Operation In the **In out parameters** field, specify values that create a map in which keys are the name of a parameter to be set on the JDBC prepared statement which is both input and output. Reference each parameter in the SQL text using a colon prefix, for example, `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. To configure the **In out parameters** field: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call doubleMyInt(:myInt) }` 3. Set the **In out parameters** field to `Edit inline`. 4. Click the plus sign (**+**) to add a new value. 5. In the new window, set the **Key** field to `myInt` and the **Value** field to `3`. The following screenshot shows the configuration in Studio: ![The Stored procedure operation with the In out parameters field configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-stored-example-2.png) Figure 2. Stored procedure with In Out parameters configuration In the XML editor, the `` and `` configuration looks like this: ```xml { call doubleMyInt(:myInt) } ``` ## Configure the Input and Output Parameters Fields in the Stored Procedure Operation In the **Output parameters** field, specify a list of values to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example, `call multiply(:value, :result)`. To configure the **Input parameters** and **Output parameters** fields: 1. In your Studio flow, select the **Stored procedure** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to the query to execute, for example: `{ call multiplyInts(:int1, :int2, :result1, :int3, :result2) }` 3. Set the **Input parameters** field to: ```xml { 'int1' : 3, 'int2' : 4, 'int3' : 5 } ``` 4. Set the **Output parameters** field to `Edit inline`. 5. Click the plus sign (**+**) to add a new value. 6. In the new window, set the **Key** field to `result1` and the **Type** field to `INTEGER`. 7. Repeat the steps 5 and 6 to add a new value, set the **Key** field to `result2` and the **Type** field to `INTEGER`. The following screenshot shows the configuration in Studio: ![The Stored procedure operation with the Input and Output parameters fields configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-stored-example-3.png) Figure 3. Stored procedure with Input and Output parameters configuration In the XML editor, the `` and `` configuration looks like this: ```xml { call multiplyInts(:int1, :int2, :result1, :int3, :result2) } #[{ 'int1' : 3, 'int2' : 4, 'int3' : 5 }] ``` ## Returning a Result Set When you call a stored procedure that returns a result set, the result set is assigned to the payload by default. To change the returning result set, configure a **Target Variable** or a **Target Value** in the **Advanced** tab of the **Stored procedure** operation configuration. The following example illustrates an MSSQL database that is initialized when creating a table named `languages` and a stored procedure named `myProc` that returns a result set: ```xml CREATE TABLE LANGUAGES (NAME VARCHAR(128), SAMPLE_TEXT VARCHAR(max)); CREATE PROCEDURE myProc AS SELECT * FROM LANGUAGES l; RETURN; ``` 1. In the **Stored procedure** operation configuration screen, set **SQL Query Text** to `{ call myProc() }`. 2. In the **Advanced** tab, set **Target Variable** to `aResult`. ![The Stored procedure operation with the Target Variable field configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-stored-example-5.png) In the XML editor, the `` configuration looks like this: ```xml ``` ### Calling Stored Procedures with Output Parameters When calling a stored procedure that returns an output parameter, ensure there is no space between the opening curly brace `{` and the return parameter name. The syntax must be `{:returnParameterName = call …​}` without any whitespace. This example illustrates calling a stored procedure with output parameters: ```xml CREATE PROCEDURE dbo.up_NOP_CreateAttachment @NOP_ID INTEGER, @Description VARCHAR(255), @DetailDescription VARCHAR(255), @DetailOriginalFileName VARCHAR(255), @FileExtensionTypeCD VARCHAR(10), @Attachment VARBINARY(MAX) AS BEGIN -- Procedure logic here RETURN @returnCode END ``` To configure the stored procedure operation: 1. In the **Stored procedure** operation configuration screen, set **SQL Query Text** to: `{:returnCode = call dbo.up_NOP_CreateAttachment(:NOP_ID, :Description, :DetailDescription, :DetailOriginalFileName, :FileExtensionTypeCD, :Attachment)}` > [!IMPORTANT] Do not include a space between the opening curly brace `{` and the colon `:` > before the return parameter name. The syntax `{ :returnCode = …​}` with a space causes an > error: "Unable to detect function 'name'". Use `{:returnCode = …​}` without the space. 2. Set the **Input parameters** field to: ```dataweave { 'NOP_ID' : vars.metadataContent.NOPID as Number, 'Description' : vars.metadataContent.Description, 'DetailDescription' : vars.metadataContent.DetailDescription, 'DetailOriginalFileName' : vars.metadataContent.DetailOriginalFileName, 'FileExtensionTypeCD' : vars.metadataContent.FileExtensionTypeCD, 'Attachment' : payload as Binary } ``` 3. Set the **Output parameters** field to `Edit inline`. 4. Click the plus sign (**+**) to add a new value. 5. In the new window, set the **Key** field to `returnCode` and the **Type** field to `INTEGER`. In the XML editor, the `` configuration looks like this: ```xml {:returnCode = call dbo.up_NOP_CreateAttachment(:NOP_ID, :Description, :DetailDescription, :DetailOriginalFileName, :FileExtensionTypeCD, :Attachment)} #[{ 'NOP_ID' : vars.metadataContent.NOPID as Number, 'Description' : vars.metadataContent.Description, 'DetailDescription' : vars.metadataContent.DetailDescription, 'DetailOriginalFileName' : vars.metadataContent.DetailOriginalFileName, 'FileExtensionTypeCD' : vars.metadataContent.FileExtensionTypeCD, 'Attachment' : payload as Binary }] ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Insert, Update, and Delete Data from a Database Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) supports the **Insert**, **Update**, and **Delete** operations that enable you to manage data from a database. In the following example, you insert, update ,and delete data from a database schema named `Products` that has a table named `electronic`. The table contains columns named `id`, `name`, `description`, `price`, and `discount`. The following SQL statement creates the table: ```sql CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ) ``` ## Configure the Insert Operation in Studio Given that the table `electronic` is already created and there is a Database Connector connection configuration named `dbConfig`, you can configure the **Insert** operation that inserts a new record in the table: 1. In your Studio flow, select the **Insert** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example: ```XML INSERT INTO electronic(name, description, price, discount) VALUES ('Coffee Machine', 'Model: XYZ99. Uses small size capsules.', 120, 5) ``` The `id` parameter is not passed in the query because it is an auto-increment key that is generated automatically by the database. ![The Insert operation configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-insert-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml INSERT INTO electronic(name, description, price, discount) VALUES ('Coffee Machine', 'Model: XYZ99. Uses small size capsules.', 120, 5) ``` ### Configure the Input Parameters Field in the Insert Operation To benefit from the advantages of input parameters, structure the equivalent SQL query as follows: 1. In your Studio flow, select the **Insert** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example: ```xml INSERT INTO electronic(name, description, price, discount) VALUES (:name, :description, :price, :discount) ``` 3. In the **Input Parameters** field, set the following parameters: ```xml { name: 'Coffee Machine', description: 'Model:XYZ99. Uses small size capsules.', price: 120, discount: 5 } ``` ![The Input Parameter field configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-insert-example-2.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml INSERT INTO electronic(name, description, price, discount) VALUES (:name, :description, :price, :discount) #[{ name: 'Coffee Machine', description: 'Model:XYZ99. Uses small size capsules.', price: 120, discount: 5}] ``` ### Configure the Auto Generate Keys Fields in the Insert Operation The **Insert** operation outputs a `Statement Result` object that contains two fields: an `affectedRows` integer that indicates how many rows were affected by the query, and a `generatedKeys` map that contains the autogenerated keys. In the following example, the output shows that the `generatedKeys` map is empty, although a row is successfully added to the table. The map is empty because this information is disabled by default to avoid overhead. ```json { "affectedRows": 1, "generatedKeys": {} } ``` To activate the information and generate keys, follow the next steps: 1. In your Studio flow, select the **Insert** operation. 2. In the **Advanced** tab, set the **Auto generate keys** field to **True**. ![The Input Parameter field configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-insert-example-3.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ... ``` If the statement generates multiple keys per affected row, you can specify which columns should be returned by setting a list that contains the desired column names, for example: 1. In your Studio flow, select the **Insert** operation. 2. In the **Advanced** tab, set the **Auto generate column names** field to `Expression or Bean reference` to set the field to a DataWeave list with a single string element. 3. Set the expression field to `['id']` to ensure that only the `id` column is returned. ![The Auto generate column names field configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-insert-example-4.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ... ``` ## Configure the Update Operation in Studio Given the `electronic` table previously defined, to update data from the table (for example, setting the discount to 10 percent for all items that have a price value above 100), configure the **Update** operation: 1. In your Studio flow, select the **Update** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example, `"UPDATE electronic SET discount = :discount WHERE price > :price"`. 3. Set the **Input parameters** field to the following parameters: ```xml { discount: 10, price: 100 } ``` ![The Update operation configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-update-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml :price"]]> ``` The `` wrapper enables you to use special characters, such as `>` or `"`, in the query. Otherwise, you must use XML-escaped versions of those characters, such as `>` and `"`. ## Configure the Delete Operation in Studio Given the `electronic` table previously defined, to remove the record with `id: 1`, configure the **Delete** operation: 1. In your Studio flow, select the **Update** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example, `DELETE FROM electronic WHERE id = :id`. 3. Set the **Input parameters** field to `{id: 1}`. ![The Update operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-delete-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml DELETE FROM electronic WHERE id = :id #[{ id: 1 }] ``` ## Insert Record Mule App Example The following example shows how to configure the **Insert** operation to create a person’s record in a database. 1. In Studio, drag the HTTP **Listener** source to the Studio canvas. 2. Set **Path** to `/person`. 3. Drag the **Insert** operation next to the **Listener** source. 4. Click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 5. In the **SQL Query Text** box, declare the following SQL text: ```xml insert into person (id, name, photo, dob) values (:ID,:NAME,:PHOTO,:DOB); ``` 6. In the **Input Parameters** field, specify a list of maps of the person record to create, which contains the parameter names as keys and the value the parameter, and in which every list item represents a row to insert: ```xml {'ID' : message.payload.parts['id'].content , 'NAME': message.payload.parts['name'].content, 'PHOTO' : message.payload.parts['photo'].content, 'DOB' : message.payload.parts['dob'].content} ``` 7. Drag a **Set Payload** component next to the **Insert** operation. 8. Set **Value** to `Person Created`. 9. Save and run your Mule application. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Insert, Update, and Delete Data from a Database Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) supports the **Insert**, **Update**, and **Delete** operations that enable you to manage data from a database. In the following example, you insert, update ,and delete data from a database schema named `Products` that has a table named `electronic`. The table contains columns named `id`, `name`, `description`, `price`, and `discount`. The following SQL statement creates the table: ```sql CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ) ``` ## Configure the Insert Operation in Studio Given that the table `electronic` is already created and there is a Database Connector connection configuration named `dbConfig`, you can configure the **Insert** operation that inserts a new record in the table: 1. In your Studio flow, select the **Insert** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example: ```XML INSERT INTO electronic(name, description, price, discount) VALUES ('Coffee Machine', 'Model: XYZ99. Uses small size capsules.', 120, 5) ``` The `id` parameter is not passed in the query because it is an auto-increment key that is generated automatically by the database. ![The Insert operation configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-insert-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml INSERT INTO electronic(name, description, price, discount) VALUES ('Coffee Machine', 'Model: XYZ99. Uses small size capsules.', 120, 5) ``` ### Configure the Input Parameters Field in the Insert Operation To benefit from the advantages of input parameters, structure the equivalent SQL query as follows: 1. In your Studio flow, select the **Insert** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example: ```xml INSERT INTO electronic(name, description, price, discount) VALUES (:name, :description, :price, :discount) ``` 3. In the **Input Parameters** field, set the following parameters: ```xml { name: 'Coffee Machine', description: 'Model:XYZ99. Uses small size capsules.', price: 120, discount: 5 } ``` ![The Input Parameter field configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-insert-example-2.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml INSERT INTO electronic(name, description, price, discount) VALUES (:name, :description, :price, :discount) #[{ name: 'Coffee Machine', description: 'Model:XYZ99. Uses small size capsules.', price: 120, discount: 5}] ``` ### Configure the Auto Generate Keys Fields in the Insert Operation The **Insert** operation outputs a `Statement Result` object that contains two fields: an `affectedRows` integer that indicates how many rows were affected by the query, and a `generatedKeys` map that contains the autogenerated keys. In the following example, the output shows that the `generatedKeys` map is empty, although a row is successfully added to the table. The map is empty because this information is disabled by default to avoid overhead. ```json { "affectedRows": 1, "generatedKeys": {} } ``` To activate the information and generate keys, follow the next steps: 1. In your Studio flow, select the **Insert** operation. 2. In the **Advanced** tab, set the **Auto generate keys** field to **True**. ![The Input Parameter field configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-insert-example-3.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ... ``` If the statement generates multiple keys per affected row, you can specify which columns should be returned by setting a list that contains the desired column names, for example: 1. In your Studio flow, select the **Insert** operation. 2. In the **Advanced** tab, set the **Auto generate column names** field to `Expression or Bean reference` to set the field to a DataWeave list with a single string element. 3. Set the expression field to `['id']` to ensure that only the `id` column is returned. ![The Auto generate column names field configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-insert-example-4.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ... ``` ## Configure the Update Operation in Studio Given the `electronic` table previously defined, to update data from the table (for example, setting the discount to 10 percent for all items that have a price value above 100), configure the **Update** operation: 1. In your Studio flow, select the **Update** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example, `"UPDATE electronic SET discount = :discount WHERE price > :price"`. 3. Set the **Input parameters** field to the following parameters: ```xml { discount: 10, price: 100 } ``` ![The Update operation configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-update-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml :price"]]> ``` The `` wrapper enables you to use special characters, such as `>` or `"`, in the query. Otherwise, you must use XML-escaped versions of those characters, such as `>` and `"`. ## Configure the Delete Operation in Studio Given the `electronic` table previously defined, to remove the record with `id: 1`, configure the **Delete** operation: 1. In your Studio flow, select the **Update** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example, `DELETE FROM electronic WHERE id = :id`. 3. Set the **Input parameters** field to `{id: 1}`. ![The Update operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-delete-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml DELETE FROM electronic WHERE id = :id #[{ id: 1 }] ``` ## Insert Record Mule App Example The following example shows how to configure the **Insert** operation to create a person’s record in a database. 1. In Studio, drag the HTTP **Listener** source to the Studio canvas. 2. Set **Path** to `/person`. 3. Drag the **Insert** operation next to the **Listener** source. 4. Click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 5. In the **SQL Query Text** box, declare the following SQL text: ```xml insert into person (id, name, photo, dob) values (:ID,:NAME,:PHOTO,:DOB); ``` 6. In the **Input Parameters** field, specify a list of maps of the person record to create, which contains the parameter names as keys and the value the parameter, and in which every list item represents a row to insert: ```xml {'ID' : message.payload.parts['id'].content , 'NAME': message.payload.parts['name'].content, 'PHOTO' : message.payload.parts['photo'].content, 'DOB' : message.payload.parts['dob'].content} ``` 7. Drag a **Set Payload** component next to the **Insert** operation. 8. Set **Value** to `Person Created`. 9. Save and run your Mule application. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Insert, Update, and Delete Data from a Database Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) supports the **Insert**, **Update**, and **Delete** operations that enable you to manage data from a database. In the following example, you insert, update ,and delete data from a database schema named `Products` that has a table named `electronic`. The table contains columns named `id`, `name`, `description`, `price`, and `discount`. The following SQL statement creates the table: ```sql CREATE TABLE electronic( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), description VARCHAR(255), price SMALLINT, discount TINYINT ) ``` ## Configure the Insert Operation in Studio Given that the table `electronic` is already created and there is a Database Connector connection configuration named `dbConfig`, you can configure the **Insert** operation that inserts a new record in the table: 1. In your Studio flow, select the **Insert** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example: ```XML INSERT INTO electronic(name, description, price, discount) VALUES ('Coffee Machine', 'Model: XYZ99. Uses small size capsules.', 120, 5) ``` The `id` parameter is not passed in the query because it is an auto-increment key that is generated automatically by the database. ![The Insert operation configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-insert-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml INSERT INTO electronic(name, description, price, discount) VALUES ('Coffee Machine', 'Model: XYZ99. Uses small size capsules.', 120, 5) ``` ### Configure the Input Parameters Field in the Insert Operation To benefit from the advantages of input parameters, structure the equivalent SQL query as follows: 1. In your Studio flow, select the **Insert** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example: ```xml INSERT INTO electronic(name, description, price, discount) VALUES (:name, :description, :price, :discount) ``` 3. In the **Input Parameters** field, set the following parameters: ```xml { name: 'Coffee Machine', description: 'Model:XYZ99. Uses small size capsules.', price: 120, discount: 5 } ``` ![The Input Parameter field configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-insert-example-2.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml INSERT INTO electronic(name, description, price, discount) VALUES (:name, :description, :price, :discount) #[{ name: 'Coffee Machine', description: 'Model:XYZ99. Uses small size capsules.', price: 120, discount: 5}] ``` ### Configure the Auto Generate Keys Fields in the Insert Operation The **Insert** operation outputs a `Statement Result` object that contains two fields: an `affectedRows` integer that indicates how many rows were affected by the query, and a `generatedKeys` map that contains the autogenerated keys. In the following example, the output shows that the `generatedKeys` map is empty, although a row is successfully added to the table. The map is empty because this information is disabled by default to avoid overhead. ```json { "affectedRows": 1, "generatedKeys": {} } ``` To activate the information and generate keys, follow the next steps: 1. In your Studio flow, select the **Insert** operation. 2. In the **Advanced** tab, set the **Auto generate keys** field to **True**. ![The Input Parameter field configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-insert-example-3.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ... ``` If the statement generates multiple keys per affected row, you can specify which columns should be returned by setting a list that contains the desired column names, for example: 1. In your Studio flow, select the **Insert** operation. 2. In the **Advanced** tab, set the **Auto generate column names** field to `Expression or Bean reference` to set the field to a DataWeave list with a single string element. 3. Set the expression field to `['id']` to ensure that only the `id` column is returned. ![The Auto generate column names field configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-insert-example-4.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ... ``` ## Configure the Update Operation in Studio Given the `electronic` table previously defined, to update data from the table (for example, setting the discount to 10 percent for all items that have a price value above 100), configure the **Update** operation: 1. In your Studio flow, select the **Update** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example, `"UPDATE electronic SET discount = :discount WHERE price > :price"`. 3. Set the **Input parameters** field to the following parameters: ```xml { discount: 10, price: 100 } ``` ![The Update operation configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-update-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml :price"]]> ``` The `` wrapper enables you to use special characters, such as `>` or `"`, in the query. Otherwise, you must use XML-escaped versions of those characters, such as `>` and `"`. ## Configure the Delete Operation in Studio Given the `electronic` table previously defined, to remove the record with `id: 1`, configure the **Delete** operation: 1. In your Studio flow, select the **Update** operation. 2. In the connector configuration screen, set the **SQL Query Text** field to the query to execute, for example, `DELETE FROM electronic WHERE id = :id`. 3. Set the **Input parameters** field to `{id: 1}`. ![The Update operation configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-delete-example-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml DELETE FROM electronic WHERE id = :id #[{ id: 1 }] ``` ## Insert Record Mule App Example The following example shows how to configure the **Insert** operation to create a person’s record in a database. 1. In Studio, drag the HTTP **Listener** source to the Studio canvas. 2. Set **Path** to `/person`. 3. Drag the **Insert** operation next to the **Listener** source. 4. Click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 5. In the **SQL Query Text** box, declare the following SQL text: ```xml insert into person (id, name, photo, dob) values (:ID,:NAME,:PHOTO,:DOB); ``` 6. In the **Input Parameters** field, specify a list of maps of the person record to create, which contains the parameter names as keys and the value the parameter, and in which every list item represents a row to insert: ```xml {'ID' : message.payload.parts['id'].content , 'NAME': message.payload.parts['name'].content, 'PHOTO' : message.payload.parts['photo'].content, 'DOB' : message.payload.parts['dob'].content} ``` 7. Drag a **Set Payload** component next to the **Insert** operation. 8. Set **Value** to `Person Created`. 9. Save and run your Mule application. In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Inserting Large File Content into a Table Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Insert** operation supports the insertion of character large objects (CLOBs) into tables. The following example illustrates how to read a large file’s content and insert it into a table that supports the type of the content. To accomplish this example, you must: - Create the table - Create the Mule application - Run and test the application with curl commands ![Example Mule app flow in Studio canvas](/mulesoft/current/en-us/db-connector/1.14/_images/database-insert-large-clobs.png) ## Create the Table Use your desired SQL client tool to run an `.sql` script with the following SQL statement to create the table: ```sql CREATE TABLE AWESOMECLOBDATA( id INT AUTO_INCREMENT PRIMARY KEY, clob_data CLOB ); ``` ## Create the Mule Application Follow these steps to create the Mule application: 1. In Studio, drag an HTTP **Listener** source to the canvas. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure an HTTP global connection. 3. Configure the HTTP global connection and click **OK**. 4. Set **Path** to `/read-insert`. 5. Drag a **Logger** component to the right of the HTTP **Listener** source. 6. Set **Message** to `Starting LARGE CLOB reading`. 7. Drag the File Connector **Read** operation to the right of the **Logger** component. 8. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 9. Set **Working Directory** to `/dir/containing/file/` to read the file properly. 10. Click **OK**. 11. Set **File Path** to `awesomeFile.json`. 12. In the **MIME Type** tab, set **MIME Type** to `application/octet-stream`. 13. Drag another **Logger** component to the right of the **Read** operation. 14. Set **Display Name** to `LARGE CLOB’s content on flow`. 15. Drag a Database Connector **Insert** operation to the right of the second **Logger** component. 16. Click the plus sign (**+**) next to the **Connector configuration** field to configure a database global connection. 17. Configure the database connection and click **OK**. 18. Set **SQL Query Text** to `INSERT INTO AWESOMECLOBDATA (clob_data) VALUES (:payload)`. The SQL text inserts a new record with the file’s content in the table. 19. Set **Input Parameters** to the expression: ```none { payload: payload } ``` 20. Drag another **Logger** component to the right of the **Insert** operation. 21. Set **Display Name** to `LARGE CLOB’s content inserted`. 22. Set **Message** to the expression `payload`. 23. Save and run your Mule application. 24. Test the app by using the following curl command in your terminal: `curl localhost:8081/read-insert`. ### Application MIME Type The `application/octet-stream` MIME type converts the content of the file to binary format enabling the proper flow of data from the **Read** operation to the **Insert** operation. For example, if you use `text/plain` MIME type, then an out-of-memory (OOM) error can arise. This can occur because the DataWeave block, defined in the **Input Parameters** field from the **Insert** operation, tries to convert to text the entire data stream from the file before delivering the data to the operation itself. You can also use the `application/json` MIME type. Though, to reference the payload use `payload.^raw` in the **Insert** operation. ## XML for the Mule Application Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [File Connector](https://docs.mulesoft.com/file-connector/1.3/) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Inserting Large File Content into a Table Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Insert** operation supports the insertion of character large objects (CLOBs) into tables. The following example illustrates how to read a large file’s content and insert it into a table that supports the type of the content. To accomplish this example, you must: - Create the table - Create the Mule application - Run and test the application with curl commands ![Example Mule app flow in Studio canvas](/mulesoft/current/en-us/db-connector/1.15/_images/database-insert-large-clobs.png) ## Create the Table Use your desired SQL client tool to run an `.sql` script with the following SQL statement to create the table: ```sql CREATE TABLE AWESOMECLOBDATA( id INT AUTO_INCREMENT PRIMARY KEY, clob_data CLOB ); ``` ## Create the Mule Application Follow these steps to create the Mule application: 1. In Studio, drag an HTTP **Listener** source to the canvas. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure an HTTP global connection. 3. Configure the HTTP global connection and click **OK**. 4. Set **Path** to `/read-insert`. 5. Drag a **Logger** component to the right of the HTTP **Listener** source. 6. Set **Message** to `Starting LARGE CLOB reading`. 7. Drag the File Connector **Read** operation to the right of the **Logger** component. 8. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 9. Set **Working Directory** to `/dir/containing/file/` to read the file properly. 10. Click **OK**. 11. Set **File Path** to `awesomeFile.json`. 12. In the **MIME Type** tab, set **MIME Type** to `application/octet-stream`. 13. Drag another **Logger** component to the right of the **Read** operation. 14. Set **Display Name** to `LARGE CLOB’s content on flow`. 15. Drag a Database Connector **Insert** operation to the right of the second **Logger** component. 16. Click the plus sign (**+**) next to the **Connector configuration** field to configure a database global connection. 17. Configure the database connection and click **OK**. 18. Set **SQL Query Text** to `INSERT INTO AWESOMECLOBDATA (clob_data) VALUES (:payload)`. The SQL text inserts a new record with the file’s content in the table. 19. Set **Input Parameters** to the expression: ```none { payload: payload } ``` 20. Drag another **Logger** component to the right of the **Insert** operation. 21. Set **Display Name** to `LARGE CLOB’s content inserted`. 22. Set **Message** to the expression `payload`. 23. Save and run your Mule application. 24. Test the app by using the following curl command in your terminal: `curl localhost:8081/read-insert`. ### Application MIME Type The `application/octet-stream` MIME type converts the content of the file to binary format enabling the proper flow of data from the **Read** operation to the **Insert** operation. For example, if you use `text/plain` MIME type, then an out-of-memory (OOM) error can arise. This can occur because the DataWeave block, defined in the **Input Parameters** field from the **Insert** operation, tries to convert to text the entire data stream from the file before delivering the data to the operation itself. You can also use the `application/json` MIME type. Though, to reference the payload use `payload.^raw` in the **Insert** operation. ## XML for the Mule Application Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [File Connector](https://docs.mulesoft.com/file-connector/1.3/) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Inserting Large File Content into a Table Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Insert** operation supports the insertion of character large objects (CLOBs) into tables. The following example illustrates how to read a large file’s content and insert it into a table that supports the type of the content. To accomplish this example, you must: - Create the table - Create the Mule application - Run and test the application with curl commands ![Example Mule app flow in Studio canvas](/mulesoft/current/en-us/db-connector/latest/_images/database-insert-large-clobs.png) ## Create the Table Use your desired SQL client tool to run an `.sql` script with the following SQL statement to create the table: ```sql CREATE TABLE AWESOMECLOBDATA( id INT AUTO_INCREMENT PRIMARY KEY, clob_data CLOB ); ``` ## Create the Mule Application Follow these steps to create the Mule application: 1. In Studio, drag an HTTP **Listener** source to the canvas. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure an HTTP global connection. 3. Configure the HTTP global connection and click **OK**. 4. Set **Path** to `/read-insert`. 5. Drag a **Logger** component to the right of the HTTP **Listener** source. 6. Set **Message** to `Starting LARGE CLOB reading`. 7. Drag the File Connector **Read** operation to the right of the **Logger** component. 8. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 9. Set **Working Directory** to `/dir/containing/file/` to read the file properly. 10. Click **OK**. 11. Set **File Path** to `awesomeFile.json`. 12. In the **MIME Type** tab, set **MIME Type** to `application/octet-stream`. 13. Drag another **Logger** component to the right of the **Read** operation. 14. Set **Display Name** to `LARGE CLOB’s content on flow`. 15. Drag a Database Connector **Insert** operation to the right of the second **Logger** component. 16. Click the plus sign (**+**) next to the **Connector configuration** field to configure a database global connection. 17. Configure the database connection and click **OK**. 18. Set **SQL Query Text** to `INSERT INTO AWESOMECLOBDATA (clob_data) VALUES (:payload)`. The SQL text inserts a new record with the file’s content in the table. 19. Set **Input Parameters** to the expression: ```none { payload: payload } ``` 20. Drag another **Logger** component to the right of the **Insert** operation. 21. Set **Display Name** to `LARGE CLOB’s content inserted`. 22. Set **Message** to the expression `payload`. 23. Save and run your Mule application. 24. Test the app by using the following curl command in your terminal: `curl localhost:8081/read-insert`. ### Application MIME Type The `application/octet-stream` MIME type converts the content of the file to binary format enabling the proper flow of data from the **Read** operation to the **Insert** operation. For example, if you use `text/plain` MIME type, then an out-of-memory (OOM) error can arise. This can occur because the DataWeave block, defined in the **Input Parameters** field from the **Insert** operation, tries to convert to text the entire data stream from the file before delivering the data to the operation itself. You can also use the `application/json` MIME type. Though, to reference the payload use `payload.^raw` in the **Insert** operation. ## XML for the Mule Application Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` > [!NOTE] If you experience performance degradation when consuming queries that return many LOB > columns, refer to > [Troubleshoot LOB Resource Release Performance](https://docs.mulesoft.com/db-connector/latest/database-connector-troubleshooting#troubleshoot-lob-resource-release-performance) > for tuning options. ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [File Connector](https://docs.mulesoft.com/file-connector/1.3/) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Query a Database Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Select** operation selects data from a database. The following examples help you configure the operation in Studio by setting **Input Parameters**, **Fetch size**, **Max rows**, **Query timeout** fields, and also how to configure dynamic queries. ## Configure the Select Operation in Studio To add and configure the **Select** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Select** operation. 2. Drag the **Select** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query to execute, for example, `SELECT * FROM PLANET WHERE name = :name`. ![Select operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-select-operation-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml SELECT * FROM PLANET WHERE name = :name ``` ## Configure the Input Parameters Field in the Select Operation To protect database queries, configure the **Input parameters** field in the **Select** operation by adding variable values to the SQL statement you execute in the database. The primary goal of the Select operation is to supply a SQL query and use DataWeave for the parameters. The parameters you provide are a map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. Use input parameters to configure the `WHERE` clause in a SQL `SELECT` statement to make the query immune to SQL injection attacks and to enable optimizations that are not possible otherwise, improving the application performance. For security reasons, do not directly write `SELECT * FROM PLANET WHERE name = #[payload] `. DataSense is available for the operation’s input and output parameters. Database Connector analyzes the query and automatically calculates the structure of the query’s output by analyzing the projection section of the SQL statement. At the same time, by comparing the conditions in the `WHERE` clause to the table structure, it generates DataSense input to help you build the DataWeave script that generates the input parameters. In the following example, you supply input parameters as key-value pairs: 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `SELECT * FROM PLANET WHERE name = :name`. 3. Set **Input Parameters** to `{'name' : payload}`. The keys use the colon character (`:`) to reference a parameter value by name. ![The Input parameters field configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-select-operation-2.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml SELECT * FROM PLANET WHERE name = :name #[{'name' : payload}] ``` > [!NOTE] Database Connector 1.4.0 accepts escaping colons in SQL Queries. If use the colon > character (`:`) in your SQL query, escape it by putting a backslash before it. This is useful when > using PostgreSQL type casting, which requires two colons before the type you are casting to, for > example: > > `SELECT price\:\:float8 FROM PRODUCT` > [!NOTE] Database Connector 1.8.0 and later accepts SQL Casting PostgreSQL and Snowflake syntaxes > through the double colon (::) expression without escaping each colon and without affecting the > behavior of escaped colons, for example: > > `SELECT MAX(modified_date)::DATE FROM sales` ## Configure Dynamic Queries in the Select Operation When you need to parameterize not only the `WHERE` clause but also parts of the query itself (for example, queries that compare tables that depend on a condition, or complex queries for which the project table columns need to vary), you can configure dynamic queries. In the following example, you configure a dynamic query by using a full expression with a string in which the table depends on a variable `$(vars.table)`. Although some of the query text is dynamic (`"SELECT * FROM $(vars.table)`), the `WHERE` clause still defines the `WHERE` condition using input parameters: in this case, `WHERE name = :name`. 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to `SELECT * FROM $(vars.table) WHERE name = :name`. 3. Set the **Input Parameters** field to `{'name' : payload}`. The following screenshot shows the configuration in Studio: ![The dynamic query configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-select-operation-3.png) Figure 1. Dynamic query configuration In the XML editor, the `` configuration looks like this: ```xml #["SELECT * FROM $(vars.table) WHERE name = :name"] #[{'name' : payload}] ``` You can apply input parameters only to parameters in a `WHERE` clause. To modify any other part of the query, use the DataWeave interpolation operator. Because the expression values may not be available at design time, using dynamic queries might throw DataWeave evaluation errors or affect the output metadata (DataSense) of the **Select** operation. To default to a value and avoid the aforementioned inconvenience, use the default modifier as follows: ```xml #["SELECT * FROM $(vars.table default ASTEROIDS) WHERE name = :name"] #[{'name' : payload}] ``` ### Stream Large Results Use streaming with queries that return many records, such as in integration use cases. Streaming is transparent and always enabled. For example, if you submit a query that returns 10K rows by attempting to fetch all those rows at once results in both performance degradation, due to the big pull from the network, and the risk of running out of memory, because all the information must be loaded into RAM. With streaming, Database Connector fetches and processes only part of the query at one time, reducing the load on the network and memory. This means that the connector does not fetch the 10K rows at once; instead, it fetches a smaller chunk, and after that chunk is consumed, it fetches the rest. You can also use repeatable streams mechanism, which enables DataWeave and other components to process the same stream many times, even in parallel. ## Configure the Fetch Size and Max Rows Fields in the Select Operation Although Mule runtime engine (Mule) enables Database Connector to manage streaming, it’s not always a good idea to move large chunks of data from the database to Mule. Even with streaming, a simple SQL query can return many rows, each one containing a lot of information. To limit the results, configure the **Fetch size** and **Max rows** fields. In the following example, you configure these fields for the **Select** operation. The syntax instructs Database Connector to fetch no more than 1000 rows (**Max rows** value) and no more than 200 rows simultaneously (**Fetch size** value), significantly reducing network and memory load. The **Fetch size** value is enforced differently by different JDBC driver providers and often defaults to `10`. The combination limits the total amount of information that is retrieved (**Max rows** value) and guarantees that the data is returned from the database over the network in smaller chunks (**Fetch size** value): 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `select * from some_table`. 3. Click **Advanced**, set **Fetch size** to `200`, and set **Max rows** to `1000`. ![.The Fetch size and Max row fields configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-select-operation-4.png) In the **Configuration XML** editor, the `fetchSize` and `maxRows` configuration looks like this: ```xml select * from some_table ``` ## Configure the Query Timeout Fields in the Select Operation The following factors often cause delays in query execution: - An inefficient query, such as one having improper indexing that iterates over many rows - A busy RDBMS or network - A lock contention To avoid timeouts when executing queries, configure the **Query timeout** and **Query time unit** fields. All Database Connector operations support setting a timeout. The following example shows how to set a timeout: 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `select * from some_table`. 3. In the **Advanced** tab, set **Query timeout** to the minimum amount of time before the JDBC driver attempts to cancel a running statement, for example, `0`. 4. Set **Query timeout unit** to a time unit that qualifies the **Query timeout**, for example, `SECONDS`. ![.The Query timeout field configuration in Studio](/mulesoft/current/en-us/db-connector/1.14/_images/database-select-operation-5.png) In the **Configuration XML** editor, the `queryTimeout` and `SECONDS` configuration looks like this: ```xml select * from some_table ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Query a Database Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Select** operation selects data from a database. The following examples help you configure the operation in Studio by setting **Input Parameters**, **Fetch size**, **Max rows**, **Query timeout** fields, and also how to configure dynamic queries. ## Configure the Select Operation in Studio To add and configure the **Select** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Select** operation. 2. Drag the **Select** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query to execute, for example, `SELECT * FROM PLANET WHERE name = :name`. ![Select operation configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-select-operation-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml SELECT * FROM PLANET WHERE name = :name ``` ## Configure the Input Parameters Field in the Select Operation To protect database queries, configure the **Input parameters** field in the **Select** operation by adding variable values to the SQL statement you execute in the database. The primary goal of the Select operation is to supply a SQL query and use DataWeave for the parameters. The parameters you provide are a map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. Use input parameters to configure the `WHERE` clause in a SQL `SELECT` statement to make the query immune to SQL injection attacks and to enable optimizations that are not possible otherwise, improving the application performance. For security reasons, do not directly write `SELECT * FROM PLANET WHERE name = #[payload] `. DataSense is available for the operation’s input and output parameters. Database Connector analyzes the query and automatically calculates the structure of the query’s output by analyzing the projection section of the SQL statement. At the same time, by comparing the conditions in the `WHERE` clause to the table structure, it generates DataSense input to help you build the DataWeave script that generates the input parameters. In the following example, you supply input parameters as key-value pairs: 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `SELECT * FROM PLANET WHERE name = :name`. 3. Set **Input Parameters** to `{'name' : payload}`. The keys use the colon character (`:`) to reference a parameter value by name. ![The Input parameters field configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-select-operation-2.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml SELECT * FROM PLANET WHERE name = :name #[{'name' : payload}] ``` > [!NOTE] Database Connector 1.4.0 accepts escaping colons in SQL Queries. If use the colon > character (`:`) in your SQL query, escape it by putting a backslash before it. This is useful when > using PostgreSQL type casting, which requires two colons before the type you are casting to, for > example: > > `SELECT price\:\:float8 FROM PRODUCT` > [!NOTE] Database Connector 1.8.0 and later accepts SQL Casting PostgreSQL and Snowflake syntaxes > through the double colon (::) expression without escaping each colon and without affecting the > behavior of escaped colons, for example: > > `SELECT MAX(modified_date)::DATE FROM sales` ## Configure Dynamic Queries in the Select Operation When you need to parameterize not only the `WHERE` clause but also parts of the query itself (for example, queries that compare tables that depend on a condition, or complex queries for which the project table columns need to vary), you can configure dynamic queries. In the following example, you configure a dynamic query by using a full expression with a string in which the table depends on a variable `$(vars.table)`. Although some of the query text is dynamic (`"SELECT * FROM $(vars.table)`), the `WHERE` clause still defines the `WHERE` condition using input parameters: in this case, `WHERE name = :name`. 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to `SELECT * FROM $(vars.table) WHERE name = :name`. 3. Set the **Input Parameters** field to `{'name' : payload}`. The following screenshot shows the configuration in Studio: ![The dynamic query configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-select-operation-3.png) Figure 1. Dynamic query configuration In the XML editor, the `` configuration looks like this: ```xml #["SELECT * FROM $(vars.table) WHERE name = :name"] #[{'name' : payload}] ``` You can apply input parameters only to parameters in a `WHERE` clause. To modify any other part of the query, use the DataWeave interpolation operator. Because the expression values may not be available at design time, using dynamic queries might throw DataWeave evaluation errors or affect the output metadata (DataSense) of the **Select** operation. To default to a value and avoid the aforementioned inconvenience, use the default modifier as follows: ```xml #["SELECT * FROM $(vars.table default ASTEROIDS) WHERE name = :name"] #[{'name' : payload}] ``` ### Stream Large Results Use streaming with queries that return many records, such as in integration use cases. Streaming is transparent and always enabled. For example, if you submit a query that returns 10K rows by attempting to fetch all those rows at once results in both performance degradation, due to the big pull from the network, and the risk of running out of memory, because all the information must be loaded into RAM. With streaming, Database Connector fetches and processes only part of the query at one time, reducing the load on the network and memory. This means that the connector does not fetch the 10K rows at once; instead, it fetches a smaller chunk, and after that chunk is consumed, it fetches the rest. You can also use repeatable streams mechanism, which enables DataWeave and other components to process the same stream many times, even in parallel. ## Configure the Fetch Size and Max Rows Fields in the Select Operation Although Mule runtime engine (Mule) enables Database Connector to manage streaming, it’s not always a good idea to move large chunks of data from the database to Mule. Even with streaming, a simple SQL query can return many rows, each one containing a lot of information. To limit the results, configure the **Fetch size** and **Max rows** fields. In the following example, you configure these fields for the **Select** operation. The syntax instructs Database Connector to fetch no more than 1000 rows (**Max rows** value) and no more than 200 rows simultaneously (**Fetch size** value), significantly reducing network and memory load. The **Fetch size** value is enforced differently by different JDBC driver providers and often defaults to `10`. The combination limits the total amount of information that is retrieved (**Max rows** value) and guarantees that the data is returned from the database over the network in smaller chunks (**Fetch size** value): 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `select * from some_table`. 3. Click **Advanced**, set **Fetch size** to `200`, and set **Max rows** to `1000`. ![.The Fetch size and Max row fields configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-select-operation-4.png) In the **Configuration XML** editor, the `fetchSize` and `maxRows` configuration looks like this: ```xml select * from some_table ``` ## Configure the Query Timeout Fields in the Select Operation The following factors often cause delays in query execution: - An inefficient query, such as one having improper indexing that iterates over many rows - A busy RDBMS or network - A lock contention To avoid timeouts when executing queries, configure the **Query timeout** and **Query time unit** fields. All Database Connector operations support setting a timeout. The following example shows how to set a timeout: 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `select * from some_table`. 3. In the **Advanced** tab, set **Query timeout** to the minimum amount of time before the JDBC driver attempts to cancel a running statement, for example, `0`. 4. Set **Query timeout unit** to a time unit that qualifies the **Query timeout**, for example, `SECONDS`. ![.The Query timeout field configuration in Studio](/mulesoft/current/en-us/db-connector/1.15/_images/database-select-operation-5.png) In the **Configuration XML** editor, the `queryTimeout` and `SECONDS` configuration looks like this: ```xml select * from some_table ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Query a Database Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) **Select** operation selects data from a database. The following examples help you configure the operation in Studio by setting **Input Parameters**, **Fetch size**, **Max rows**, **Query timeout** fields, and also how to configure dynamic queries. ## Configure the Select Operation in Studio To add and configure the **Select** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `database` and select the **Select** operation. 2. Drag the **Select** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the database connection information and click **OK**. 5. Set the **SQL Query Text** field to the SQL query to execute, for example, `SELECT * FROM PLANET WHERE name = :name`. ![Select operation configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-select-operation-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml SELECT * FROM PLANET WHERE name = :name ``` ## Configure the Input Parameters Field in the Select Operation To protect database queries, configure the **Input parameters** field in the **Select** operation by adding variable values to the SQL statement you execute in the database. The primary goal of the Select operation is to supply a SQL query and use DataWeave for the parameters. The parameters you provide are a map in which keys are the name of an input parameter to be set on the JDBC prepared statement. Reference each parameter in the SQL text using a colon prefix, for example `where id = :myParamName`. The map’s values contain the actual assignation for each parameter. Use input parameters to configure the `WHERE` clause in a SQL `SELECT` statement to make the query immune to SQL injection attacks and to enable optimizations that are not possible otherwise, improving the application performance. For security reasons, do not directly write `SELECT * FROM PLANET WHERE name = #[payload] `. DataSense is available for the operation’s input and output parameters. Database Connector analyzes the query and automatically calculates the structure of the query’s output by analyzing the projection section of the SQL statement. At the same time, by comparing the conditions in the `WHERE` clause to the table structure, it generates DataSense input to help you build the DataWeave script that generates the input parameters. In the following example, you supply input parameters as key-value pairs: 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `SELECT * FROM PLANET WHERE name = :name`. 3. Set **Input Parameters** to `{'name' : payload}`. The keys use the colon character (`:`) to reference a parameter value by name. ![The Input parameters field configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-select-operation-2.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml SELECT * FROM PLANET WHERE name = :name #[{'name' : payload}] ``` > [!NOTE] Database Connector 1.4.0 accepts escaping colons in SQL Queries. If use the colon > character (`:`) in your SQL query, escape it by putting a backslash before it. This is useful when > using PostgreSQL type casting, which requires two colons before the type you are casting to, for > example: > > `SELECT price\:\:float8 FROM PRODUCT` > [!NOTE] Database Connector 1.8.0 and later accepts SQL Casting PostgreSQL and Snowflake syntaxes > through the double colon (::) expression without escaping each colon and without affecting the > behavior of escaped colons, for example: > > `SELECT MAX(modified_date)::DATE FROM sales` ## Configure Dynamic Queries in the Select Operation When you need to parameterize not only the `WHERE` clause but also parts of the query itself (for example, queries that compare tables that depend on a condition, or complex queries for which the project table columns need to vary), you can configure dynamic queries. In the following example, you configure a dynamic query by using a full expression with a string in which the table depends on a variable `$(vars.table)`. Although some of the query text is dynamic (`"SELECT * FROM $(vars.table)`), the `WHERE` clause still defines the `WHERE` condition using input parameters: in this case, `WHERE name = :name`. 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set the **SQL Query Text** field to `SELECT * FROM $(vars.table) WHERE name = :name`. 3. Set the **Input Parameters** field to `{'name' : payload}`. The following screenshot shows the configuration in Studio: ![The dynamic query configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-select-operation-3.png) Figure 1. Dynamic query configuration In the XML editor, the `` configuration looks like this: ```xml #["SELECT * FROM $(vars.table) WHERE name = :name"] #[{'name' : payload}] ``` You can apply input parameters only to parameters in a `WHERE` clause. To modify any other part of the query, use the DataWeave interpolation operator. Because the expression values may not be available at design time, using dynamic queries might throw DataWeave evaluation errors or affect the output metadata (DataSense) of the **Select** operation. To default to a value and avoid the aforementioned inconvenience, use the default modifier as follows: ```xml #["SELECT * FROM $(vars.table default ASTEROIDS) WHERE name = :name"] #[{'name' : payload}] ``` ### Stream Large Results Use streaming with queries that return many records, such as in integration use cases. Streaming is transparent and always enabled. For example, if you submit a query that returns 10K rows by attempting to fetch all those rows at once results in both performance degradation, due to the big pull from the network, and the risk of running out of memory, because all the information must be loaded into RAM. With streaming, Database Connector fetches and processes only part of the query at one time, reducing the load on the network and memory. This means that the connector does not fetch the 10K rows at once; instead, it fetches a smaller chunk, and after that chunk is consumed, it fetches the rest. You can also use repeatable streams mechanism, which enables DataWeave and other components to process the same stream many times, even in parallel. ## Configure the Fetch Size and Max Rows Fields in the Select Operation Although Mule runtime engine (Mule) enables Database Connector to manage streaming, it’s not always a good idea to move large chunks of data from the database to Mule. Even with streaming, a simple SQL query can return many rows, each one containing a lot of information. To limit the results, configure the **Fetch size** and **Max rows** fields. In the following example, you configure these fields for the **Select** operation. The syntax instructs Database Connector to fetch no more than 1000 rows (**Max rows** value) and no more than 200 rows simultaneously (**Fetch size** value), significantly reducing network and memory load. The **Fetch size** value is enforced differently by different JDBC driver providers and often defaults to `10`. The combination limits the total amount of information that is retrieved (**Max rows** value) and guarantees that the data is returned from the database over the network in smaller chunks (**Fetch size** value): 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `select * from some_table`. 3. Click **Advanced**, set **Fetch size** to `200`, and set **Max rows** to `1000`. ![.The Fetch size and Max row fields configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-select-operation-4.png) In the **Configuration XML** editor, the `fetchSize` and `maxRows` configuration looks like this: ```xml select * from some_table ``` ## Configure the Query Timeout Fields in the Select Operation The following factors often cause delays in query execution: - An inefficient query, such as one having improper indexing that iterates over many rows - A busy RDBMS or network - A lock contention To avoid timeouts when executing queries, configure the **Query timeout** and **Query time unit** fields. All Database Connector operations support setting a timeout. The following example shows how to set a timeout: 1. In your Studio flow, select the **Select** operation. 2. In the operation configuration screen, set **SQL Query Text** to `select * from some_table`. 3. In the **Advanced** tab, set **Query timeout** to the minimum amount of time before the JDBC driver attempts to cancel a running statement, for example, `0`. 4. Set **Query timeout unit** to a time unit that qualifies the **Query timeout**, for example, `SECONDS`. ![.The Query timeout field configuration in Studio](/mulesoft/current/en-us/db-connector/latest/_images/database-select-operation-5.png) In the **Configuration XML** editor, the `queryTimeout` and `SECONDS` configuration looks like this: ```xml select * from some_table ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Query a Single Record from a Database Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for Database (Database Connector) **Query single** operation enables you to execute an SQL query that returns a single record (row) from a database and access the result payload without any additional transformations. This operation does not stream any of the returned fields. When the query is executed, all the values of the returned row are read into memory and returned in the payload. You must be careful, however, because if your row is too large, you could run out of memory. Also, if you use connection pooling you do not have to worry about your application running out of connections, because this operation returns the connection to the pool immediately after the query is executed. You invoke the **Query single** operation in the same way as you invoke the **Select** operation; however, you always get a single result using the **Query single** operation, regardless of the number of records returned by the actual SQL query. The following example shows how to configure the operation in a Mule application that retrieves books information from a table in a MySQL database. To accomplish this example, you must: - Run an SQL statement that creates a table called `BOOK` and inserts seven records of book information (title, author, bookshopName, isbn, price). - Configure the SQL database connection. - Create the Mule application. - Run the application and then test it by using with curl commands. ![Query a single record from a database flow](/mulesoft/current/en-us/db-connector/1.14/_images/database-query-single-flow.png) Figure 1. Query a Single Record from a Database flow ## Create the Table in the Database Before configuring the SQL database connection and creating the Mule app, run the following SQL statement to create a table called `BOOK` and insert seven book records. An incremental `id` is associated with each new book added into to table. For example, the first book added to the table has an `id` equal to `1`, the second book has an `id` equal to `2`, and so on. ```sql USE SYS; CREATE TABLE BOOK( id MEDIUMINT NOT NULL AUTO_INCREMENT, title VARCHAR(100), author VARCHAR(100), bookshopName VARCHAR(100), isbn VARCHAR(13), price SMALLINT, PRIMARY KEY (id) ); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Good Omens', 'Terry Pratchett and Neil Gaiman', 'A.Z. Fell and Co.', '9780060853983', 50); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('A Wizard of Earthsea', 'Ursula K. Le Guin', 'A.Z. Fell and Co.', '9780547773742', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('IT', 'Stephen King', 'A.Z. Fell and Co.', '9781508297123', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('The Nice and Accurate Prophecies of Agnes Nutter', 'Agnes Nutter', 'A.Z. Fell and Co.', '000000000000', 200); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Cujo', 'Stephen King', 'A.Z. Fell and Co.', '9781501192241', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Nation', 'Terry Pratchett', 'A.Z. Fell and Co.', '9780552557795', 30); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('The Ocean at the End of the Lane', 'Neil Gaiman', 'A.Z. Fell and Co.', '9780062459367', 30); ``` ## Configure a MySQL Database Connection After you create the table, go to Anypoint Studio to configure the MySQL database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, complete the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set the **Name** field to `dbConfig`. 10. In the **Connection** field, select **MySQL Connection**. 11. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. In the **Connection** section, complete the following fields: - **Host**: `localhost` - **Port**: `3306` - **User**: `root` - **Password**: `mysql` - **Database**: `sys` 13. On the **Advanced** tab, set the **Pooling profile** field to **Edit inline**. 14. Set the **Max pool size** field to `5`. 15. Click **Test Connection** to confirm that Mule can connect to the database. 16. Click **OK**. The following screenshot shows the HTTP **Listener** global element configuration: ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-1.png) Figure 2. HTTP Listener configuration The following screenshots show the Database global element configuration: ![The database general configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-2.png) Figure 3. Database Config General configuration ## Create, Configure, Run and Test the Mule Application After you configure the MySQL database connection, create, configure, run, and test the Mule app: ### Create a Flow by Configuring the HTTP Listener and Set Variable Component To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set the **Path** field to `/select/book/{maxId}`. The `maxId` value parameter indicates how many books records to retrieve from the database. You can increment this value regardless of the number of maximum connections you configured in your database connection pool. 4. In the **Mime Type** tab, set the **Mime Type** field to `application/json`. 5. In the **Advanced** tab, set the **Allowed methods** field to `GET`. 6. Drag a **Set Variable** component to the right of the **Listener** source. This component creates a new variable to save the database results that will be obtained from the **Query single** operation. 7. Set the **Name** field to `bookCollection` and the **Value** field to `#[[]]`: ![The Set Variable component configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-3.png) Figure 4. Set Variable configuration ### Configure the For Each Component, the Query Single Operation, and the Set Payload Component Continue creating the Mule application using a **For Each** component to iterate the number of books requested by **HTTP Listener**. Then retrieve the book information using the **Query single** operation, and save the results in a payload variable: 1. Drag a **For Each** component to the right of **Set Variable**. 2. Set the **Collection** field to `#[1 to attributes.uriParams.maxId as Number]`. This expression iterates the collection of books in the table, from the first book (`1`) to the number of books set in the `maxId` parameter, when performing the HTTP request `/select/book/{maxId}`. ![For Each configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-4.png) Figure 5. For Each configuration 3. Drag the **Query single** operation into the **For Each** component. 4. Set the **Connector configuration** field to `Database_Config` to connect to the MySQL database configuration. 5. Set the **SQL Query Text** field to `SELECT id, title, author FROM BOOK WHERE id = :id`. This query selects the books information from the database. 6. Set the **Input Parameters** field to `![CDATA[#[{'id': payload }]]]`. This expression maps the key parameter `id` (referenced in the previous **SQL Query Text** expression) to `payload` which is the result value of books information retrieved using the `SELECT` query. ![Query single configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-5.png) Figure 6. Query single configuration 7. Drag another **Set Variable** component to the right of the **Query single** operation. 8. Set the **Name** field to `bookCollection` and the **Value** field to `#[vars.bookCollection ++ [payload]]`. The original variable `bookCollection` now saves the `payload` of the retrieved book information. 9. Drag a **Set Payload** component to the right of the **For Each** component. 10. Set the **Value** field to `#[vars.bookCollection]` to save the variable content as a new output payload: ![Set Payload configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-querysingle-example-6.png) Figure 7. Set Payload configuration ### Run and Test the Mule Application To run and test the Mule application: 1. Save the project in Studio. 2. Test the app by running `curl localhost:8081/select/book/7` at the command line. This command selects the first seven books of the table, regardless of the maximum number of connections (`5`) configured in the pool. ## XML for Querying a Single Record from a Database Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml SELECT id, title, author FROM BOOK WHERE id = :id ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.14/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Query a Single Record from a Database Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for Database (Database Connector) **Query single** operation enables you to execute an SQL query that returns a single record (row) from a database and access the result payload without any additional transformations. This operation does not stream any of the returned fields. When the query is executed, all the values of the returned row are read into memory and returned in the payload. You must be careful, however, because if your row is too large, you could run out of memory. Also, if you use connection pooling you do not have to worry about your application running out of connections, because this operation returns the connection to the pool immediately after the query is executed. You invoke the **Query single** operation in the same way as you invoke the **Select** operation; however, you always get a single result using the **Query single** operation, regardless of the number of records returned by the actual SQL query. The following example shows how to configure the operation in a Mule application that retrieves books information from a table in a MySQL database. To accomplish this example, you must: - Run an SQL statement that creates a table called `BOOK` and inserts seven records of book information (title, author, bookshopName, isbn, price). - Configure the SQL database connection. - Create the Mule application. - Run the application and then test it by using with curl commands. ![Query a single record from a database flow](/mulesoft/current/en-us/db-connector/1.15/_images/database-query-single-flow.png) Figure 1. Query a Single Record from a Database flow ## Create the Table in the Database Before configuring the SQL database connection and creating the Mule app, run the following SQL statement to create a table called `BOOK` and insert seven book records. An incremental `id` is associated with each new book added into to table. For example, the first book added to the table has an `id` equal to `1`, the second book has an `id` equal to `2`, and so on. ```sql USE SYS; CREATE TABLE BOOK( id MEDIUMINT NOT NULL AUTO_INCREMENT, title VARCHAR(100), author VARCHAR(100), bookshopName VARCHAR(100), isbn VARCHAR(13), price SMALLINT, PRIMARY KEY (id) ); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Good Omens', 'Terry Pratchett and Neil Gaiman', 'A.Z. Fell and Co.', '9780060853983', 50); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('A Wizard of Earthsea', 'Ursula K. Le Guin', 'A.Z. Fell and Co.', '9780547773742', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('IT', 'Stephen King', 'A.Z. Fell and Co.', '9781508297123', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('The Nice and Accurate Prophecies of Agnes Nutter', 'Agnes Nutter', 'A.Z. Fell and Co.', '000000000000', 200); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Cujo', 'Stephen King', 'A.Z. Fell and Co.', '9781501192241', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Nation', 'Terry Pratchett', 'A.Z. Fell and Co.', '9780552557795', 30); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('The Ocean at the End of the Lane', 'Neil Gaiman', 'A.Z. Fell and Co.', '9780062459367', 30); ``` ## Configure a MySQL Database Connection After you create the table, go to Anypoint Studio to configure the MySQL database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, complete the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set the **Name** field to `dbConfig`. 10. In the **Connection** field, select **MySQL Connection**. 11. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. In the **Connection** section, complete the following fields: - **Host**: `localhost` - **Port**: `3306` - **User**: `root` - **Password**: `mysql` - **Database**: `sys` 13. On the **Advanced** tab, set the **Pooling profile** field to **Edit inline**. 14. Set the **Max pool size** field to `5`. 15. Click **Test Connection** to confirm that Mule can connect to the database. 16. Click **OK**. The following screenshot shows the HTTP **Listener** global element configuration: ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-1.png) Figure 2. HTTP Listener configuration The following screenshots show the Database global element configuration: ![The database general configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-2.png) Figure 3. Database Config General configuration ## Create, Configure, Run and Test the Mule Application After you configure the MySQL database connection, create, configure, run, and test the Mule app: ### Create a Flow by Configuring the HTTP Listener and Set Variable Component To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set the **Path** field to `/select/book/{maxId}`. The `maxId` value parameter indicates how many books records to retrieve from the database. You can increment this value regardless of the number of maximum connections you configured in your database connection pool. 4. In the **Mime Type** tab, set the **Mime Type** field to `application/json`. 5. In the **Advanced** tab, set the **Allowed methods** field to `GET`. 6. Drag a **Set Variable** component to the right of the **Listener** source. This component creates a new variable to save the database results that will be obtained from the **Query single** operation. 7. Set the **Name** field to `bookCollection` and the **Value** field to `#[[]]`: ![The Set Variable component configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-3.png) Figure 4. Set Variable configuration ### Configure the For Each Component, the Query Single Operation, and the Set Payload Component Continue creating the Mule application using a **For Each** component to iterate the number of books requested by **HTTP Listener**. Then retrieve the book information using the **Query single** operation, and save the results in a payload variable: 1. Drag a **For Each** component to the right of **Set Variable**. 2. Set the **Collection** field to `#[1 to attributes.uriParams.maxId as Number]`. This expression iterates the collection of books in the table, from the first book (`1`) to the number of books set in the `maxId` parameter, when performing the HTTP request `/select/book/{maxId}`. ![For Each configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-4.png) Figure 5. For Each configuration 3. Drag the **Query single** operation into the **For Each** component. 4. Set the **Connector configuration** field to `Database_Config` to connect to the MySQL database configuration. 5. Set the **SQL Query Text** field to `SELECT id, title, author FROM BOOK WHERE id = :id`. This query selects the books information from the database. 6. Set the **Input Parameters** field to `![CDATA[#[{'id': payload }]]]`. This expression maps the key parameter `id` (referenced in the previous **SQL Query Text** expression) to `payload` which is the result value of books information retrieved using the `SELECT` query. ![Query single configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-5.png) Figure 6. Query single configuration 7. Drag another **Set Variable** component to the right of the **Query single** operation. 8. Set the **Name** field to `bookCollection` and the **Value** field to `#[vars.bookCollection ++ [payload]]`. The original variable `bookCollection` now saves the `payload` of the retrieved book information. 9. Drag a **Set Payload** component to the right of the **For Each** component. 10. Set the **Value** field to `#[vars.bookCollection]` to save the variable content as a new output payload: ![Set Payload configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-querysingle-example-6.png) Figure 7. Set Payload configuration ### Run and Test the Mule Application To run and test the Mule application: 1. Save the project in Studio. 2. Test the app by running `curl localhost:8081/select/book/7` at the command line. This command selects the first seven books of the table, regardless of the maximum number of connections (`5`) configured in the pool. ## XML for Querying a Single Record from a Database Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml SELECT id, title, author FROM BOOK WHERE id = :id ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/1.15/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Query a Single Record from a Database Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for Database (Database Connector) **Query single** operation enables you to execute an SQL query that returns a single record (row) from a database and access the result payload without any additional transformations. This operation does not stream any of the returned fields. When the query is executed, all the values of the returned row are read into memory and returned in the payload. You must be careful, however, because if your row is too large, you could run out of memory. Also, if you use connection pooling you do not have to worry about your application running out of connections, because this operation returns the connection to the pool immediately after the query is executed. You invoke the **Query single** operation in the same way as you invoke the **Select** operation; however, you always get a single result using the **Query single** operation, regardless of the number of records returned by the actual SQL query. The following example shows how to configure the operation in a Mule application that retrieves books information from a table in a MySQL database. To accomplish this example, you must: - Run an SQL statement that creates a table called `BOOK` and inserts seven records of book information (title, author, bookshopName, isbn, price). - Configure the SQL database connection. - Create the Mule application. - Run the application and then test it by using with curl commands. ![Query a single record from a database flow](/mulesoft/current/en-us/db-connector/latest/_images/database-query-single-flow.png) Figure 1. Query a Single Record from a Database flow ## Create the Table in the Database Before configuring the SQL database connection and creating the Mule app, run the following SQL statement to create a table called `BOOK` and insert seven book records. An incremental `id` is associated with each new book added into to table. For example, the first book added to the table has an `id` equal to `1`, the second book has an `id` equal to `2`, and so on. ```sql USE SYS; CREATE TABLE BOOK( id MEDIUMINT NOT NULL AUTO_INCREMENT, title VARCHAR(100), author VARCHAR(100), bookshopName VARCHAR(100), isbn VARCHAR(13), price SMALLINT, PRIMARY KEY (id) ); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Good Omens', 'Terry Pratchett and Neil Gaiman', 'A.Z. Fell and Co.', '9780060853983', 50); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('A Wizard of Earthsea', 'Ursula K. Le Guin', 'A.Z. Fell and Co.', '9780547773742', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('IT', 'Stephen King', 'A.Z. Fell and Co.', '9781508297123', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('The Nice and Accurate Prophecies of Agnes Nutter', 'Agnes Nutter', 'A.Z. Fell and Co.', '000000000000', 200); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Cujo', 'Stephen King', 'A.Z. Fell and Co.', '9781501192241', 20); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('Nation', 'Terry Pratchett', 'A.Z. Fell and Co.', '9780552557795', 30); INSERT INTO BOOK(title, author, bookshopName, isbn, price) VALUES('The Ocean at the End of the Lane', 'Neil Gaiman', 'A.Z. Fell and Co.', '9780062459367', 30); ``` ## Configure a MySQL Database Connection After you create the table, go to Anypoint Studio to configure the MySQL database connection: 1. Create a new Mule project in Studio. 2. Navigate to the **Global Elements** view. 3. Click **Create** to open the **Choose Global Type** view. 4. In the **Filter** field, type `http`, select **HTTP Listener config**, and click **OK**. This configuration is for the HTTP **Listener** source that initiates the Mule application flow. 5. In the **HTTP Listener config** window, complete the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Global Elements** view, click **Create** to open the **Choose Global Type** view. 8. In the **Filter** field, type `database`, select **Database Config**, and click **OK**. 9. In the **Database Config** window, set the **Name** field to `dbConfig`. 10. In the **Connection** field, select **MySQL Connection**. 11. Click **Configure** to add the required MySQL JDBC driver and select one of: - **Add recommended library** Install the recommended library. - **Use local file** Install the library using a local file. - **Add Maven dependency** Install a Maven dependency to add to the project. 12. In the **Connection** section, complete the following fields: - **Host**: `localhost` - **Port**: `3306` - **User**: `root` - **Password**: `mysql` - **Database**: `sys` 13. On the **Advanced** tab, set the **Pooling profile** field to **Edit inline**. 14. Set the **Max pool size** field to `5`. 15. Click **Test Connection** to confirm that Mule can connect to the database. 16. Click **OK**. The following screenshot shows the HTTP **Listener** global element configuration: ![The HTTP Listener global element configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-1.png) Figure 2. HTTP Listener configuration The following screenshots show the Database global element configuration: ![The database general configuration setting the Host, Port, User, and Password fields.](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-2.png) Figure 3. Database Config General configuration ## Create, Configure, Run and Test the Mule Application After you configure the MySQL database connection, create, configure, run, and test the Mule app: ### Create a Flow by Configuring the HTTP Listener and Set Variable Component To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. In the **Connector configuration** field, select the `HTTP_Listener_config` global configuration. 3. Set the **Path** field to `/select/book/{maxId}`. The `maxId` value parameter indicates how many books records to retrieve from the database. You can increment this value regardless of the number of maximum connections you configured in your database connection pool. 4. In the **Mime Type** tab, set the **Mime Type** field to `application/json`. 5. In the **Advanced** tab, set the **Allowed methods** field to `GET`. 6. Drag a **Set Variable** component to the right of the **Listener** source. This component creates a new variable to save the database results that will be obtained from the **Query single** operation. 7. Set the **Name** field to `bookCollection` and the **Value** field to `#[[]]`: ![The Set Variable component configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-3.png) Figure 4. Set Variable configuration ### Configure the For Each Component, the Query Single Operation, and the Set Payload Component Continue creating the Mule application using a **For Each** component to iterate the number of books requested by **HTTP Listener**. Then retrieve the book information using the **Query single** operation, and save the results in a payload variable: 1. Drag a **For Each** component to the right of **Set Variable**. 2. Set the **Collection** field to `#[1 to attributes.uriParams.maxId as Number]`. This expression iterates the collection of books in the table, from the first book (`1`) to the number of books set in the `maxId` parameter, when performing the HTTP request `/select/book/{maxId}`. ![For Each configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-4.png) Figure 5. For Each configuration 3. Drag the **Query single** operation into the **For Each** component. 4. Set the **Connector configuration** field to `Database_Config` to connect to the MySQL database configuration. 5. Set the **SQL Query Text** field to `SELECT id, title, author FROM BOOK WHERE id = :id`. This query selects the books information from the database. 6. Set the **Input Parameters** field to `![CDATA[#[{'id': payload }]]]`. This expression maps the key parameter `id` (referenced in the previous **SQL Query Text** expression) to `payload` which is the result value of books information retrieved using the `SELECT` query. ![Query single configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-5.png) Figure 6. Query single configuration 7. Drag another **Set Variable** component to the right of the **Query single** operation. 8. Set the **Name** field to `bookCollection` and the **Value** field to `#[vars.bookCollection ++ [payload]]`. The original variable `bookCollection` now saves the `payload` of the retrieved book information. 9. Drag a **Set Payload** component to the right of the **For Each** component. 10. Set the **Value** field to `#[vars.bookCollection]` to save the variable content as a new output payload: ![Set Payload configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-querysingle-example-6.png) Figure 7. Set Payload configuration ### Run and Test the Mule Application To run and test the Mule application: 1. Save the project in Studio. 2. Test the app by running `curl localhost:8081/select/book/7` at the command line. This command selects the first seven books of the table, regardless of the maximum number of connections (`5`) configured in the pool. ## XML for Querying a Single Record from a Database Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml SELECT id, title, author FROM BOOK WHERE id = :id ``` ## See Also - [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Troubleshooting Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for Database (Database Connector), become familiar with the information about enabling verbose logging, troubleshooting pooling profile connections, troubleshooting Snowflake JDBC driver, and interpreting commonly thrown messages. Database Connector follows the standards and guidelines detailed by the JDBC library (working with Java SE). ## Enable Verbose Logging To get a better understanding of why an application’s interaction with the database is failing, temporarily enable verbose logging for Database Connector. Choose one of two options to enable verbose logging: manually change the `log4j2.xml` file or via Anypoint Runtime Manager if you are using CloudHub APIs. Remember to always disable the enhanced verbosity after troubleshooting because it affects your Mule application performance. To enable verbose logging in the configuration file: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. Add an `` tag inside the `` tag: ```xml ... ... ``` 6. Save your application changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. To enable verbose logging in Anypoint Runtime Manager: 1. Access Anypoint Runtime Manager. 2. Navigate to the API configuration. 3. In the **Logging** subtab, add the `org.mule.extension.db` and `org.mule.db.commons` packages at DEBUG level. 4. Apply the changes. ## Troubleshoot Pooling Profiles Connections Making the Flow Hang Using a pooling profile that provides fewer connections than the flow requires can make the entire flow hang. To resolve this issue: One solution is to increase the size of the pool. When that’s not possible, use Anypoint Connector for Virtual Machine (VM Connector) to shorten the life of the connection to match the life of a VM message. This way, every call to the **Stored procedure** operation is executed, its result is consumed, and the connection associated with the operation is closed and returned to the pool. The following example shows how to use pooling profiles with the **Stored procedure** operation and VM Connector. In this example, When the `foreach` element reaches the eleventh iteration, the **Stored procedure** operation doesn’t hang, because the pool is able to provide a connection: ```xml ``` ## Understand Select and Stored Procedure Operations Warning Exceptions When the Database Connector **Select** and **Stored procedure** operations execute correctly but do not return results, Mule runtime engine (Mule) returns a `WARN` exception message instead of throwing the exception. For the **Select** operation, the behavior occurs when executing an invalid SQL statement, and for the **Store procedure** operation, when there is an error within a set of statements that can collapse the procedure. In fact, JDBC returns a series of `ResultSets`, `UpdateCounts`, and `Exceptions`. Mule does not throw an exception for the flow to catch it because the root cause is in the driver’s behavior. Some drivers comply strictly with JDBC and properly throw an exception at execution time, but other drivers do not. Therefore, adding in the connector code the behavior of throwing an exception would break backward compatibility for Mule apps that do not expect an exception. For the **Select** operation, Mule logs a `WARN` exception when a subquery returns more than one value and that result is used for filtering or as an expression. Mule returns the warning as soon as the operation’s result is paginated and not when it’s executed. For example, for the following SQL statement: ```xml ``` Mule logs the following `WARN` exception: ```xml WARN 2021-06-01 10:04:33,323 [[MuleRuntime].io.10: [some-mule-app].some-mule-app.BLOCKING @...] [event: ...] org.mule.extension.db.internal.result.resultset.ResultSetIterator: Unable to determine if there are more records com.microsoft.sqlserver.jdbc.SQLServerException: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. ``` For the **Store procedure** operation, Mule logs a `WARN` exception when a stored procedure contains multiple statements and one or more of them fail. Mule returns the warning as soon as the operation’s result is consumed and not when it’s executed. For example, for the following SQL Stored Procedure: ```xml CREATE PROCEDURE dbo.SomeProcedure AS BEGIN BEGIN TRY select 1/0; END TRY BEGIN CATCH THROW 50000, 'Divide by zero error encountered.', 255; END CATCH END ``` Mule logs the following `WARN` exception: ```xml WARN 2021-06-02 09:38:14,624 [[MuleRuntime].io.10: [some-mule-app].some-mule-app.BLOCKING @...] [event: ...] org.mule.extension.db.internal.result.statement.StatementResultIterator: Unable to determine if there are more statement results com.microsoft.sqlserver.jdbc.SQLServerException: 'The record does not exist.' ``` ## Troubleshoot Snowflake JDBC Driver That Throws an Exception for a Stored Procedure Some drivers have their own specifications when calling stored procedures. Running the application when you set the callable statement with curly brackets (`{` and `}`), for example, `{call doubleMyInt(:myInt)}`, causes the Snowflake JDBC driver to throw the following exception: `net.snowflake.client.jdbc.SnowflakeSQLException: Unsupported feature 'call'` To resolve this issue: For Snowflake JDBC driver, set the callable statement without the curly brackets `{` and `}`, for example: `call doubleMyInt(:myInt)` ## Troubleshoot CloudHub with Static IP Failure on Deployment Deploying a CloudHub application with a static IP throws a database test connection error making the process fail. This occurs because the test is performed before the static IP gets assigned. The following stack trace shows the test connection error `Could not obtain connection from data source`: ```xml [2021-03-05 00:26:11.262] INFO org.mule.runtime.module.extension.internal.runtime.config.LifecycleAwareConfigurationInstance [[MuleRuntime].uber.02: [iagsatellite-snowflake-sys-api-v1-dev].uber@org.mule.runtime.module.extension.internal.runtime.config.LifecycleAwareConfigurationInstance.testConnectivity:179 @10f9d7dc]: Connectivity test failed for config 'Database_Config'. Application deployment will continue. Error was: Could not obtain connection from data source org.mule.runtime.api.connection.ConnectionException: Could not obtain connection from data source ``` To resolve this issue: Set the following system property to the deployment `-DdoTestConnectivity=false`. ## Troubleshoot Oracle’s XML Extensions using System Properties To use Oracle XML extensions, you must add Oracle jar files as dependencies. One of these jar files is `xmlparserv2.jar`, which exports XML parser capabilities via the Java SPI (Service Provider Interface). When internal parts of Mule use this parser, it can break some Mule components' expectations and cause XML parsing errors, such as the following: ```xml : XML-24509: (Error) Duplicated definition for: 'identifiedType' : XML-24509: (Error) Duplicated definition for: 'beans' : XML-24509: (Error) Duplicated definition for: 'description' ``` To deal with this issue, do either of the following: - Add the `xmlparserv2.jar` file as an additional plugin dependency in the Database Connector, so the dependency is visible only from within the connector. Though, that won’t work if you need to share an Oracle connection among modules, which is the case if you want to provide a DataSource as a Spring configured bean. - Disable the XML parser SPI lookup by setting the following system properties, so Mule internal components always get the XML parser they expect: System Properties: ```xml -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl ``` These properties avoid any trouble if, for instance, you need to set up Oracle .jars as shared libraries. For more information about how to set system properties, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## Troubleshoot TCP Keep Alive for Oracle Driver If a query or stored procedure takes more than 15–30 minutes to execute, the firewall or network device might close the connection. To prevent this, set the TCP Keep Alive for the Oracle provider by adding this flag as a JVM parameter: \-Doracle.net.keepAlive=true This flag ensures the connection remains active. ## Understand Common Throws Here is a list of common throws messages and how to interpret them. - DB:BAD\_SQL\_SYNTAX The provided SQL query contains invalid syntax. - DB:CANNOT\_LOAD\_DRIVER Database Connector cannot load the JDBC driver. - DB:CANNOT\_REACH Database Connector cannot establish a connection with the RDBMS. - DB:CONNECTIVITY Any of several possible connectivity issues, including poorly configured connections, lack of a database response while waiting for results or fetching rows, loss of database connection, and so on. - DB:INVALID\_DATABASE The connection to the RDBMS is established but the database doesn't exist. - DB:INVALID\_CREDENTIALS The database rejects the provided credentials. - DB:QUERY\_EXECUTION The query execution failed. - DB:RETRY\_EXHAUSTED All reconnection attempts failed. ## See Also - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: Database Connector version: 1.15 --- # Troubleshooting Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for Database (Database Connector), become familiar with the information about enabling verbose logging, troubleshooting pooling profile connections, troubleshooting Snowflake JDBC driver, and interpreting commonly thrown messages. Database Connector follows the standards and guidelines detailed by the JDBC library (working with Java SE). ## Enable Verbose Logging To get a better understanding of why an application’s interaction with the database is failing, temporarily enable verbose logging for Database Connector. Choose one of two options to enable verbose logging: manually change the `log4j2.xml` file or via Anypoint Runtime Manager if you are using CloudHub APIs. Remember to always disable the enhanced verbosity after troubleshooting because it affects your Mule application performance. To enable verbose logging in the configuration file: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. Add an `` tag inside the `` tag: ```xml ... ... ``` 6. Save your application changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. To enable verbose logging in Anypoint Runtime Manager: 1. Access Anypoint Runtime Manager. 2. Navigate to the API configuration. 3. In the **Logging** subtab, add the `org.mule.extension.db` and `org.mule.db.commons` packages at DEBUG level. 4. Apply the changes. ## Troubleshoot Pooling Profiles Connections Making the Flow Hang Using a pooling profile that provides fewer connections than the flow requires can make the entire flow hang. To resolve this issue: One solution is to increase the size of the pool. When that’s not possible, use Anypoint Connector for Virtual Machine (VM Connector) to shorten the life of the connection to match the life of a VM message. This way, every call to the **Stored procedure** operation is executed, its result is consumed, and the connection associated with the operation is closed and returned to the pool. The following example shows how to use pooling profiles with the **Stored procedure** operation and VM Connector. In this example, When the `foreach` element reaches the eleventh iteration, the **Stored procedure** operation doesn’t hang, because the pool is able to provide a connection: ```xml ``` ## Understand Select and Stored Procedure Operations Warning Exceptions When the Database Connector **Select** and **Stored procedure** operations execute correctly but do not return results, Mule runtime engine (Mule) returns a `WARN` exception message instead of throwing the exception. For the **Select** operation, the behavior occurs when executing an invalid SQL statement, and for the **Store procedure** operation, when there is an error within a set of statements that can collapse the procedure. In fact, JDBC returns a series of `ResultSets`, `UpdateCounts`, and `Exceptions`. Mule does not throw an exception for the flow to catch it because the root cause is in the driver’s behavior. Some drivers comply strictly with JDBC and properly throw an exception at execution time, but other drivers do not. Therefore, adding in the connector code the behavior of throwing an exception would break backward compatibility for Mule apps that do not expect an exception. For the **Select** operation, Mule logs a `WARN` exception when a subquery returns more than one value and that result is used for filtering or as an expression. Mule returns the warning as soon as the operation’s result is paginated and not when it’s executed. For example, for the following SQL statement: ```xml ``` Mule logs the following `WARN` exception: ```xml WARN 2021-06-01 10:04:33,323 [[MuleRuntime].io.10: [some-mule-app].some-mule-app.BLOCKING @...] [event: ...] org.mule.extension.db.internal.result.resultset.ResultSetIterator: Unable to determine if there are more records com.microsoft.sqlserver.jdbc.SQLServerException: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. ``` For the **Store procedure** operation, Mule logs a `WARN` exception when a stored procedure contains multiple statements and one or more of them fail. Mule returns the warning as soon as the operation’s result is consumed and not when it’s executed. For example, for the following SQL Stored Procedure: ```xml CREATE PROCEDURE dbo.SomeProcedure AS BEGIN BEGIN TRY select 1/0; END TRY BEGIN CATCH THROW 50000, 'Divide by zero error encountered.', 255; END CATCH END ``` Mule logs the following `WARN` exception: ```xml WARN 2021-06-02 09:38:14,624 [[MuleRuntime].io.10: [some-mule-app].some-mule-app.BLOCKING @...] [event: ...] org.mule.extension.db.internal.result.statement.StatementResultIterator: Unable to determine if there are more statement results com.microsoft.sqlserver.jdbc.SQLServerException: 'The record does not exist.' ``` ## Troubleshoot Snowflake JDBC Driver That Throws an Exception for a Stored Procedure Some drivers have their own specifications when calling stored procedures. Running the application when you set the callable statement with curly brackets (`{` and `}`), for example, `{call doubleMyInt(:myInt)}`, causes the Snowflake JDBC driver to throw the following exception: `net.snowflake.client.jdbc.SnowflakeSQLException: Unsupported feature 'call'` To resolve this issue: For Snowflake JDBC driver, set the callable statement without the curly brackets `{` and `}`, for example: `call doubleMyInt(:myInt)` ## Troubleshoot CloudHub with Static IP Failure on Deployment Deploying a CloudHub application with a static IP throws a database test connection error making the process fail. This occurs because the test is performed before the static IP gets assigned. The following stack trace shows the test connection error `Could not obtain connection from data source`: ```xml [2021-03-05 00:26:11.262] INFO org.mule.runtime.module.extension.internal.runtime.config.LifecycleAwareConfigurationInstance [[MuleRuntime].uber.02: [iagsatellite-snowflake-sys-api-v1-dev].uber@org.mule.runtime.module.extension.internal.runtime.config.LifecycleAwareConfigurationInstance.testConnectivity:179 @10f9d7dc]: Connectivity test failed for config 'Database_Config'. Application deployment will continue. Error was: Could not obtain connection from data source org.mule.runtime.api.connection.ConnectionException: Could not obtain connection from data source ``` To resolve this issue: Set the following system property to the deployment `-DdoTestConnectivity=false`. ## Troubleshoot Oracle’s XML Extensions using System Properties To use Oracle XML extensions, you must add Oracle jar files as dependencies. One of these jar files is `xmlparserv2.jar`, which exports XML parser capabilities via the Java SPI (Service Provider Interface). When internal parts of Mule use this parser, it can break some Mule components' expectations and cause XML parsing errors, such as the following: ```xml : XML-24509: (Error) Duplicated definition for: 'identifiedType' : XML-24509: (Error) Duplicated definition for: 'beans' : XML-24509: (Error) Duplicated definition for: 'description' ``` To deal with this issue, do either of the following: - Add the `xmlparserv2.jar` file as an additional plugin dependency in the Database Connector, so the dependency is visible only from within the connector. Though, that won’t work if you need to share an Oracle connection among modules, which is the case if you want to provide a DataSource as a Spring configured bean. - Disable the XML parser SPI lookup by setting the following system properties, so Mule internal components always get the XML parser they expect: System Properties: ```xml -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl ``` These properties avoid any trouble if, for instance, you need to set up Oracle .jars as shared libraries. For more information about how to set system properties, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## Troubleshoot TCP Keep Alive for Oracle Driver If a query or stored procedure takes more than 15–30 minutes to execute, the firewall or network device might close the connection. To prevent this, set the TCP Keep Alive for the Oracle provider by adding this flag as a JVM parameter: \-Doracle.net.keepAlive=true This flag ensures the connection remains active. ## Understand Common Throws Here is a list of common throws messages and how to interpret them. - DB:BAD\_SQL\_SYNTAX The provided SQL query contains invalid syntax. - DB:CANNOT\_LOAD\_DRIVER Database Connector cannot load the JDBC driver. - DB:CANNOT\_REACH Database Connector cannot establish a connection with the RDBMS. - DB:CONNECTIVITY Any of several possible connectivity issues, including poorly configured connections, lack of a database response while waiting for results or fetching rows, loss of database connection, and so on. - DB:INVALID\_DATABASE The connection to the RDBMS is established but the database doesn't exist. - DB:INVALID\_CREDENTIALS The database rejects the provided credentials. - DB:QUERY\_EXECUTION The query execution failed. - DB:RETRY\_EXHAUSTED All reconnection attempts failed. ## See Also - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: Database Connector version: 1.16 is-latest-version: true --- # Troubleshooting Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for Database (Database Connector), become familiar with the information about enabling verbose logging, troubleshooting pooling profile connections, troubleshooting Snowflake JDBC driver, and interpreting commonly thrown messages. Database Connector follows the standards and guidelines detailed by the JDBC library (working with Java SE). ## Enable Verbose Logging To get a better understanding of why an application’s interaction with the database is failing, temporarily enable verbose logging for Database Connector. Choose one of two options to enable verbose logging: manually change the `log4j2.xml` file or via Anypoint Runtime Manager if you are using CloudHub APIs. Remember to always disable the enhanced verbosity after troubleshooting because it affects your Mule application performance. To enable verbose logging in the configuration file: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. Add an `` tag inside the `` tag: ```xml ... ... ``` 6. Save your application changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. To enable verbose logging in Anypoint Runtime Manager: 1. Access Anypoint Runtime Manager. 2. Navigate to the API configuration. 3. In the **Logging** subtab, add the `org.mule.extension.db` and `org.mule.db.commons` packages at DEBUG level. 4. Apply the changes. ## Troubleshoot Pooling Profiles Connections Making the Flow Hang Using a pooling profile that provides fewer connections than the flow requires can make the entire flow hang. To resolve this issue: One solution is to increase the size of the pool. When that’s not possible, use Anypoint Connector for Virtual Machine (VM Connector) to shorten the life of the connection to match the life of a VM message. This way, every call to the **Stored procedure** operation is executed, its result is consumed, and the connection associated with the operation is closed and returned to the pool. The following example shows how to use pooling profiles with the **Stored procedure** operation and VM Connector. In this example, When the `foreach` element reaches the eleventh iteration, the **Stored procedure** operation doesn’t hang, because the pool is able to provide a connection: ```xml ``` ## Understand Select and Stored Procedure Operations Warning Exceptions When the Database Connector **Select** and **Stored procedure** operations execute correctly but do not return results, Mule runtime engine (Mule) returns a `WARN` exception message instead of throwing the exception. For the **Select** operation, the behavior occurs when executing an invalid SQL statement, and for the **Store procedure** operation, when there is an error within a set of statements that can collapse the procedure. In fact, JDBC returns a series of `ResultSets`, `UpdateCounts`, and `Exceptions`. Mule does not throw an exception for the flow to catch it because the root cause is in the driver’s behavior. Some drivers comply strictly with JDBC and properly throw an exception at execution time, but other drivers do not. Therefore, adding in the connector code the behavior of throwing an exception would break backward compatibility for Mule apps that do not expect an exception. For the **Select** operation, Mule logs a `WARN` exception when a subquery returns more than one value and that result is used for filtering or as an expression. Mule returns the warning as soon as the operation’s result is paginated and not when it’s executed. For example, for the following SQL statement: ```xml ``` Mule logs the following `WARN` exception: ```xml WARN 2021-06-01 10:04:33,323 [[MuleRuntime].io.10: [some-mule-app].some-mule-app.BLOCKING @...] [event: ...] org.mule.extension.db.internal.result.resultset.ResultSetIterator: Unable to determine if there are more records com.microsoft.sqlserver.jdbc.SQLServerException: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. ``` For the **Store procedure** operation, Mule logs a `WARN` exception when a stored procedure contains multiple statements and one or more of them fail. Mule returns the warning as soon as the operation’s result is consumed and not when it’s executed. For example, for the following SQL Stored Procedure: ```xml CREATE PROCEDURE dbo.SomeProcedure AS BEGIN BEGIN TRY select 1/0; END TRY BEGIN CATCH THROW 50000, 'Divide by zero error encountered.', 255; END CATCH END ``` Mule logs the following `WARN` exception: ```xml WARN 2021-06-02 09:38:14,624 [[MuleRuntime].io.10: [some-mule-app].some-mule-app.BLOCKING @...] [event: ...] org.mule.extension.db.internal.result.statement.StatementResultIterator: Unable to determine if there are more statement results com.microsoft.sqlserver.jdbc.SQLServerException: 'The record does not exist.' ``` ## Troubleshoot Snowflake JDBC Driver That Throws an Exception for a Stored Procedure Some drivers have their own specifications when calling stored procedures. Running the application when you set the callable statement with curly brackets (`{` and `}`), for example, `{call doubleMyInt(:myInt)}`, causes the Snowflake JDBC driver to throw the following exception: `net.snowflake.client.jdbc.SnowflakeSQLException: Unsupported feature 'call'` To resolve this issue: For Snowflake JDBC driver, set the callable statement without the curly brackets `{` and `}`, for example: `call doubleMyInt(:myInt)` ## Troubleshoot CloudHub with Static IP Failure on Deployment Deploying a CloudHub application with a static IP throws a database test connection error making the process fail. This occurs because the test is performed before the static IP gets assigned. The following stack trace shows the test connection error `Could not obtain connection from data source`: ```xml [2021-03-05 00:26:11.262] INFO org.mule.runtime.module.extension.internal.runtime.config.LifecycleAwareConfigurationInstance [[MuleRuntime].uber.02: [iagsatellite-snowflake-sys-api-v1-dev].uber@org.mule.runtime.module.extension.internal.runtime.config.LifecycleAwareConfigurationInstance.testConnectivity:179 @10f9d7dc]: Connectivity test failed for config 'Database_Config'. Application deployment will continue. Error was: Could not obtain connection from data source org.mule.runtime.api.connection.ConnectionException: Could not obtain connection from data source ``` To resolve this issue: Set the following system property to the deployment `-DdoTestConnectivity=false`. ## Troubleshoot Oracle’s XML Extensions using System Properties To use Oracle XML extensions, you must add Oracle jar files as dependencies. One of these jar files is `xmlparserv2.jar`, which exports XML parser capabilities via the Java SPI (Service Provider Interface). When internal parts of Mule use this parser, it can break some Mule components' expectations and cause XML parsing errors, such as the following: ```xml : XML-24509: (Error) Duplicated definition for: 'identifiedType' : XML-24509: (Error) Duplicated definition for: 'beans' : XML-24509: (Error) Duplicated definition for: 'description' ``` To deal with this issue, do either of the following: - Add the `xmlparserv2.jar` file as an additional plugin dependency in the Database Connector, so the dependency is visible only from within the connector. Though, that won’t work if you need to share an Oracle connection among modules, which is the case if you want to provide a DataSource as a Spring configured bean. - Disable the XML parser SPI lookup by setting the following system properties, so Mule internal components always get the XML parser they expect: System Properties: ```xml -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl ``` These properties avoid any trouble if, for instance, you need to set up Oracle .jars as shared libraries. For more information about how to set system properties, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## Troubleshoot TCP Keep Alive for Oracle Driver If a query or stored procedure takes more than 15–30 minutes to execute, the firewall or network device might close the connection. To prevent this, set the TCP Keep Alive for the Oracle provider by adding this flag as a JVM parameter: \-Doracle.net.keepAlive=true This flag ensures the connection remains active. ## Troubleshoot Duplicate Column Names in Query Metadata When a SELECT query or stored procedure returns multiple columns with the same name (for example, after a JOIN without aliases), the connector’s metadata resolution might fail with a duplicate key error. To resolve this issue, set the **Use Column Numbers** parameter to `true` in the operation’s Advanced tab. This causes the connector to use positional column numbers (1, 2, 3…​) instead of column names as keys in the result metadata. ```xml ``` > [!NOTE] This parameter is available for the **Select**, **Query Single**, and **Stored Procedure** > operations. ## Troubleshoot LOB Resource Release Performance When queries return large numbers of LOB (CLOB, BLOB, or SQLXML) columns, the connector’s default behavior of calling `free()` on each LOB object after consumption can cause performance degradation. This is particularly noticeable with Oracle databases, where each `free()` call triggers a server round-trip. To tune LOB resource release behavior, set the following system property: \-Dmule.db.connector.lob.free.strategy= The available strategies are:
StrategyBehaviorRecommended Use Case

EAGER (default)

Calls free() on each LOB as soon as its content is consumed.

General use. Ensures immediate resource release.

DEFERRED

Accumulates LOB references and executes all free() calls in a single batch when the ResultSet is closed.

Reduces per-row round-trips for queries returning many LOB columns.

NONE

Does not call free() at all. LOB resources are released passively by the JDBC driver when the ResultSet, Statement, or Connection is closed.

Use when performance is critical and passive release is acceptable.

Common symptoms that indicate you should change this setting: - Performance degradation with Oracle queries returning many CLOB/BLOB columns (consider `DEFERRED` or `NONE`) - Connection pool exhaustion when consuming LOB-heavy result sets (verify pool sizing first, then consider `DEFERRED`) For more information about how to set system properties, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## Troubleshoot C3P0 Statement Cache Errors Under High Concurrency Under high concurrency, you might encounter the following error from the C3P0 connection pool: ```text java.lang.RuntimeException: Inconsistency!!! Statement culled from deathmarch failed to be removed by removeStatement(...)! ``` This error is caused by a race condition in the internal `HashMap` of C3P0’s prepared statement cache. Although this issue was reported in C3P0 GitHub issue #192, it might not be fully resolved in all scenarios. To work around this issue, disable the C3P0 statement cache and enable the JDBC driver’s implicit statement cache instead. For Oracle, configure the following connection properties: 1. Set C3P0’s `preparedStatementCacheSize` to `0` in the pooling profile to disable C3P0’s statement cache: ```xml ``` 2. Enable Oracle’s implicit statement cache by setting the following system property: \-Doracle.jdbc.implicitStatementCacheSize=50 This configuration delegates statement caching to the Oracle JDBC driver, which handles concurrent access more reliably than C3P0’s internal cache. ## Understand Common Throws Here is a list of common throws messages and how to interpret them. - DB:BAD\_SQL\_SYNTAX The provided SQL query contains invalid syntax. - DB:CANNOT\_LOAD\_DRIVER Database Connector cannot load the JDBC driver. - DB:CANNOT\_REACH Database Connector cannot establish a connection with the RDBMS. - DB:CONNECTIVITY Any of several possible connectivity issues, including poorly configured connections, lack of a database response while waiting for results or fetching rows, loss of database connection, and so on. - DB:INVALID\_DATABASE The connection to the RDBMS is established but the database doesn't exist. - DB:INVALID\_CREDENTIALS The database rejects the provided credentials. - DB:QUERY\_EXECUTION The query execution failed. - DB:RETRY\_EXHAUSTED All reconnection attempts failed. ## See Also - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: Database Connector version: 1.14 --- # Using Anypoint Code Builder to Configure Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) initiates a flow when a specified condition is met. You can configure one of these triggers to use with Database Connector: - **Database > On Table Row** Initiates a flow by selecting from a table at a regular interval and generates one message per obtained row - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met. See [Scheduler ()](https://docs.mulesoft.com/anypoint-code-builder/acb-component-scheduler). For example, to configure the **On Table Row** source: 1. Add the **On Table Row** component to the canvas. 2. Click the **On Table Row** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Table

Name of the database table to select from.

Yes

Watermark column

Values taken from this column are used to filter the contents of the next poll, so that only rows with a greater watermark value are processed.

No

Id column

Used in conjunction with Watermark column, which is the name of the column to consider as the row ID. If provided, this component ensures that the same row is not processed twice by concurrent polls.

No

Scheduling strategy

Triggers execution of the flow based on a time-based condition. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Scheduling Strategy in XML.

Yes

4. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Transactional action

Type of joining action that operations can use in transactions:

  • NONE (Default)

  • ALWAYS_BEGIN

No

Transaction type

The type of transaction to create (XA or Local). Availability depends on the Mule runtime version. Local is the default.

No

Primary node only

Select this option to execute the On Table Row trigger only on the primary node when running in a cluster.

No

Redelivery policy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Redelivery Policy.

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Reconnection strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

## Configuring a Connector in XML Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Code Builder: - If you manually code a Mule runtime engine (Mule) app in XML from the Anypoint Code Builder XML editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Anypoint Code Builder, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. This example shows how the namespace statements are placed in the `` XML block: ```xml ``` The Apache Maven `pom.xml` file generated by Anypoint Code Builder contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml {group-id-exchange} {artifact-id-exchange} x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for the connector. 4. Select the connector. 5. Click **Dependency Snippets**. ## Configuring a Database Connection Database (Database Connector) can connect to any database for which a JDBC driver is available. The following XML examples show how to connect to the most popular databases such as Derby, Microsoft SQL Server, MySQL, Oracle, and a generic database. ### Configuring a Derby Database Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a Generic Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a Microsoft SQL Server Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a MySQL Database Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring an Oracle Connection In the XML editor, the configuration looks like this: ```xml ``` ## Configuring the JDBC Driver After you configure the connections, add the JDBC driver. The following example shows how to add a driver for MySQL Database: 1. Add a Maven dependency to your project’s `pom.xml` file: ```xml mysql mysql-connector-java 5.1.48 ``` 2. Configure your `pom.xml` file so that Mule exposes the driver dependency to Database Connector: ```xml org.mule.tools.maven mule-maven-plugin 1.0.0 mysql mysql-connector-java ``` ## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Configuring Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the Bulk Delete Operation This operation enables delete operations to execute at various times using different parameter bindings and a single database statement. 1. Add the **Bulk delete** operation to the canvas. 2. Click the **Bulk delete** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

### Configuring the Bulk Insert Operation This operation enables inserts to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing a single insert operation at various times. 1. Add the **Bulk insert** operation to the canvas. 2. Click the **Bulk insert** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Bulk Update Operation This operation enables updates to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing one single update operation at various times. 1. Add the **Bulk update** operation to the canvas. 2. Click the **Bulk update** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Delete Operation This operation deletes data in a database. 1. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

2. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Execute DDL Operation This operation allows execution of DDL queries against a database. 1. Add the **Execute DDL** operation to the canvas. 2. Click the **Execute DDL** component on the canvas. 3. In the **General** tab, in **SQL Query Text**, add text for the SQL query to execute. 4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Execute Script Operation This operation executes a SQL script in a single database statement. The script is executed as you provide it, without any parameter binding. 1. Add the **Execute Script** operation to the canvas. 2. Click the **Execute Script** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

SQL Query Text

Text for the SQL query to execute.

No

Script path

Specifies the location of a file to load. The file can point to a resource on the classpath or on a disk.

No

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Insert Operation This operation inserts data into a database. 1. Add the **Insert** operation to the canvas. 2. Click the **Insert** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Query Single Operation This operation selects a single data record from a database. If you provide a SQL query that returns more than one row, only the first record is processed and returned. This operation doesn’t use streaming, which means that immediately after performing the **Query Single** operation, the complete contents of the selected record is loaded into memory. 1. Add the **Query Single** operation to the canvas. 2. Click the **Query Single** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Select Operation This operation queries data from a database. To prevent loading all the results at once, which can lead to performance and memory issues, results are streamed automatically. This means that pages of _fetchSize_ rows are loaded when needed. If this operation is performed inside a transaction (that is, within a **Try** scope component) and that transaction is closed before consuming the data, accessing the results that haven’t been loaded fails. 1. Add the **Select** operation to the canvas. 2. Click the **Select** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Streaming Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See include::connectors::partial$acb-xml-examples.adoc[tag="streaming-strategy"].

No

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Stored Procedure Operation This operation invokes a stored procedure on the database. When the stored procedure returns one or more `ResultSet` instances, results are not read all at once. Instead, results are automatically streamed to prevent performance and memory issues. This behavior means that pages of `_fetchSize_` rows are loaded lazily when needed. If the **Stored procedure** operation is performed inside a transaction (for example, in a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded fails. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. 1. Add the **Stored Procedure** operation to the canvas. 2. Click the **Stored Procedure** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

SQL Query Text

Text of the SQL query to execute.

Yes

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

Input-Output Parameters

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Stored Procedure.

No

Output Parameters

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Stored Procedure.

No

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Update Operation This operation updates data in a database. 1. Add the **Update** operation to the canvas. 2. Click the **Update** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

## XML Examples ### Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ### Configuring the Streaming Strategy in XML You can configure how Mule handles streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` ### Configuring the Scheduling Strategy in XML ### Fixed Frequency This is an example of the fixed frequency scheduling strategy XML using the default values: ```xml ``` ### Cron For more complex scheduling strategies, you can use a cron expression: ```xml ``` ## Creating a New Configuration XML File Anypoint Code Builder creates the initial Mule configuration XML file in `src/main/mule` within the Mule project. This file contains global configurations and flow structures. You can create additional configuration files, for example, to store global configurations. To create a new XML configuration file: 1. In the Explorer view, right-click the **mule** folder (`src/main/mule`) and select **New File**. Alternatively, use the menu. Show me how Select the `mule` folder, and then: - In the desktop IDE, select **File** > **New Mule Configuration File**. - In the cloud IDE, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-menu.png) (menu) icon, and select **File** > **New File**. 2. Enter a name for the new file with the `.xml` extension. 3. In the Editor view for the new file, press Ctrl+Space to display available options. 4. Select **Empty mule configuration**: ![New Mule configuration option in auto-correct](/mulesoft/current/en-us/anypoint-code-builder/_images/int-new-mule-config.png) This command adds the following code to the file: ```xml ``` ## See Also - [Anypoint Code Builder Overview](https://docs.mulesoft.com/anypoint-code-builder/) - [Creating Integrations](https://docs.mulesoft.com/anypoint-code-builder/int-create-integrations) - [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb) - [Anypoint Code Builder Components and Commands Reference](https://docs.mulesoft.com/anypoint-code-builder/acb-reference) - [Defining and Securing Properties for a Mule Application](https://docs.mulesoft.com/anypoint-code-builder/int-create-secure-configs) - [Triggering Flows in Your Development Environment](https://docs.mulesoft.com/anypoint-code-builder/int-trigger-flows) - [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components) - [Debugging Mule Applications](https://docs.mulesoft.com/anypoint-code-builder/int-debug-mule-apps) - [Salesforce Help](https://help.salesforce.com) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation) - [Configure Streaming Strategies](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) --- product: Database Connector version: 1.15 --- # Using Anypoint Code Builder to Configure Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) initiates a flow when a specified condition is met. You can configure one of these triggers to use with Database Connector: - **Database > On Table Row** Initiates a flow by selecting from a table at a regular interval and generates one message per obtained row - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met. See [Scheduler ()](https://docs.mulesoft.com/anypoint-code-builder/acb-component-scheduler). For example, to configure the **On Table Row** source: 1. Add the **On Table Row** component to the canvas. 2. Click the **On Table Row** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Table

Name of the database table to select from.

Yes

Watermark column

Values taken from this column are used to filter the contents of the next poll, so that only rows with a greater watermark value are processed.

No

Id column

Used in conjunction with Watermark column, which is the name of the column to consider as the row ID. If provided, this component ensures that the same row is not processed twice by concurrent polls.

No

Scheduling strategy

Triggers execution of the flow based on a time-based condition. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Scheduling Strategy in XML.

Yes

4. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Transactional action

Type of joining action that operations can use in transactions:

  • NONE (Default)

  • ALWAYS_BEGIN

No

Transaction type

The type of transaction to create (XA or Local). Availability depends on the Mule runtime version. Local is the default.

No

Primary node only

Select this option to execute the On Table Row trigger only on the primary node when running in a cluster.

No

Redelivery policy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Redelivery Policy.

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Reconnection strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

## Configuring a Connector in XML Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Code Builder: - If you manually code a Mule runtime engine (Mule) app in XML from the Anypoint Code Builder XML editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Anypoint Code Builder, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. This example shows how the namespace statements are placed in the `` XML block: ```xml ``` The Apache Maven `pom.xml` file generated by Anypoint Code Builder contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml {group-id-exchange} {artifact-id-exchange} x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for the connector. 4. Select the connector. 5. Click **Dependency Snippets**. ## Configuring a Database Connection Database (Database Connector) can connect to any database for which a JDBC driver is available. The following XML examples show how to connect to the most popular databases such as Derby, Microsoft SQL Server, MySQL, Oracle, and a generic database. ### Configuring a Derby Database Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a Generic Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a Microsoft SQL Server Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a MySQL Database Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring an Oracle Connection In the XML editor, the configuration looks like this: ```xml ``` ## Configuring the JDBC Driver After you configure the connections, add the JDBC driver. The following example shows how to add a driver for MySQL Database: 1. Add a Maven dependency to your project’s `pom.xml` file: ```xml mysql mysql-connector-java 5.1.48 ``` 2. Configure your `pom.xml` file so that Mule exposes the driver dependency to Database Connector: ```xml org.mule.tools.maven mule-maven-plugin 1.0.0 mysql mysql-connector-java ``` ## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Configuring Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the Bulk Delete Operation This operation enables delete operations to execute at various times using different parameter bindings and a single database statement. 1. Add the **Bulk delete** operation to the canvas. 2. Click the **Bulk delete** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

### Configuring the Bulk Insert Operation This operation enables inserts to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing a single insert operation at various times. 1. Add the **Bulk insert** operation to the canvas. 2. Click the **Bulk insert** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Bulk Update Operation This operation enables updates to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing one single update operation at various times. 1. Add the **Bulk update** operation to the canvas. 2. Click the **Bulk update** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Delete Operation This operation deletes data in a database. 1. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

2. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Execute DDL Operation This operation allows execution of DDL queries against a database. 1. Add the **Execute DDL** operation to the canvas. 2. Click the **Execute DDL** component on the canvas. 3. In the **General** tab, in **SQL Query Text**, add text for the SQL query to execute. 4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Execute Script Operation This operation executes a SQL script in a single database statement. The script is executed as you provide it, without any parameter binding. 1. Add the **Execute Script** operation to the canvas. 2. Click the **Execute Script** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

SQL Query Text

Text for the SQL query to execute.

No

Script path

Specifies the location of a file to load. The file can point to a resource on the classpath or on a disk.

No

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Insert Operation This operation inserts data into a database. 1. Add the **Insert** operation to the canvas. 2. Click the **Insert** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Query Single Operation This operation selects a single data record from a database. If you provide a SQL query that returns more than one row, only the first record is processed and returned. This operation doesn’t use streaming, which means that immediately after performing the **Query Single** operation, the complete contents of the selected record is loaded into memory. 1. Add the **Query Single** operation to the canvas. 2. Click the **Query Single** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Select Operation This operation queries data from a database. To prevent loading all the results at once, which can lead to performance and memory issues, results are streamed automatically. This means that pages of _fetchSize_ rows are loaded when needed. If this operation is performed inside a transaction (that is, within a **Try** scope component) and that transaction is closed before consuming the data, accessing the results that haven’t been loaded fails. 1. Add the **Select** operation to the canvas. 2. Click the **Select** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Streaming Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See include::connectors::partial$acb-xml-examples.adoc[tag="streaming-strategy"].

No

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Stored Procedure Operation This operation invokes a stored procedure on the database. When the stored procedure returns one or more `ResultSet` instances, results are not read all at once. Instead, results are automatically streamed to prevent performance and memory issues. This behavior means that pages of `_fetchSize_` rows are loaded lazily when needed. If the **Stored procedure** operation is performed inside a transaction (for example, in a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded fails. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. 1. Add the **Stored Procedure** operation to the canvas. 2. Click the **Stored Procedure** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

SQL Query Text

Text of the SQL query to execute.

Yes

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

Input-Output Parameters

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Stored Procedure.

No

Output Parameters

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Stored Procedure.

No

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Update Operation This operation updates data in a database. 1. Add the **Update** operation to the canvas. 2. Click the **Update** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

## XML Examples ### Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ### Configuring the Streaming Strategy in XML You can configure how Mule handles streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` ### Configuring the Scheduling Strategy in XML ### Fixed Frequency This is an example of the fixed frequency scheduling strategy XML using the default values: ```xml ``` ### Cron For more complex scheduling strategies, you can use a cron expression: ```xml ``` ## Creating a New Configuration XML File Anypoint Code Builder creates the initial Mule configuration XML file in `src/main/mule` within the Mule project. This file contains global configurations and flow structures. You can create additional configuration files, for example, to store global configurations. To create a new XML configuration file: 1. In the Explorer view, right-click the **mule** folder (`src/main/mule`) and select **New File**. Alternatively, use the menu. Show me how Select the `mule` folder, and then: - In the desktop IDE, select **File** > **New Mule Configuration File**. - In the cloud IDE, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-menu.png) (menu) icon, and select **File** > **New File**. 2. Enter a name for the new file with the `.xml` extension. 3. In the Editor view for the new file, press Ctrl+Space to display available options. 4. Select **Empty mule configuration**: ![New Mule configuration option in auto-correct](/mulesoft/current/en-us/anypoint-code-builder/_images/int-new-mule-config.png) This command adds the following code to the file: ```xml ``` ## See Also - [Anypoint Code Builder Overview](https://docs.mulesoft.com/anypoint-code-builder/) - [Creating Integrations](https://docs.mulesoft.com/anypoint-code-builder/int-create-integrations) - [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb) - [Anypoint Code Builder Components and Commands Reference](https://docs.mulesoft.com/anypoint-code-builder/acb-reference) - [Defining and Securing Properties for a Mule Application](https://docs.mulesoft.com/anypoint-code-builder/int-create-secure-configs) - [Triggering Flows in Your Development Environment](https://docs.mulesoft.com/anypoint-code-builder/int-trigger-flows) - [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components) - [Debugging Mule Applications](https://docs.mulesoft.com/anypoint-code-builder/int-debug-mule-apps) - [Salesforce Help](https://help.salesforce.com) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation) - [Configure Streaming Strategies](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) --- product: Database Connector version: 1.16 is-latest-version: true --- # Using Anypoint Code Builder to Configure Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) initiates a flow when a specified condition is met. You can configure one of these triggers to use with Database Connector: - **Database > On Table Row** Initiates a flow by selecting from a table at a regular interval and generates one message per obtained row - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met. See [Scheduler ()](https://docs.mulesoft.com/anypoint-code-builder/acb-component-scheduler). For example, to configure the **On Table Row** source: 1. Add the **On Table Row** component to the canvas. 2. Click the **On Table Row** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Table

Name of the database table to select from.

Yes

Watermark column

Values taken from this column are used to filter the contents of the next poll, so that only rows with a greater watermark value are processed.

No

Id column

Used in conjunction with Watermark column, which is the name of the column to consider as the row ID. If provided, this component ensures that the same row is not processed twice by concurrent polls.

No

Scheduling strategy

Triggers execution of the flow based on a time-based condition. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Scheduling Strategy in XML.

Yes

4. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Transactional action

Type of joining action that operations can use in transactions:

  • NONE (Default)

  • ALWAYS_BEGIN

No

Transaction type

The type of transaction to create (XA or Local). Availability depends on the Mule runtime version. Local is the default.

No

Primary node only

Select this option to execute the On Table Row trigger only on the primary node when running in a cluster.

No

Redelivery policy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Redelivery Policy.

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Reconnection strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

## Configuring a Connector in XML Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Code Builder: - If you manually code a Mule runtime engine (Mule) app in XML from the Anypoint Code Builder XML editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Anypoint Code Builder, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. This example shows how the namespace statements are placed in the `` XML block: ```xml ``` The Apache Maven `pom.xml` file generated by Anypoint Code Builder contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml {group-id-exchange} {artifact-id-exchange} x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for the connector. 4. Select the connector. 5. Click **Dependency Snippets**. ## Configuring a Database Connection Database (Database Connector) can connect to any database for which a JDBC driver is available. The following XML examples show how to connect to the most popular databases such as Derby, Microsoft SQL Server, MySQL, Oracle, and a generic database. ### Configuring a Derby Database Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a Generic Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a Microsoft SQL Server Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring a MySQL Database Connection In the XML editor, the configuration looks like this: ```xml ``` ### Configuring an Oracle Connection In the XML editor, the configuration looks like this: ```xml ``` ## Configuring the JDBC Driver After you configure the connections, add the JDBC driver. The following example shows how to add a driver for MySQL Database: 1. Add a Maven dependency to your project’s `pom.xml` file: ```xml mysql mysql-connector-java 5.1.48 ``` 2. Configure your `pom.xml` file so that Mule exposes the driver dependency to Database Connector: ```xml org.mule.tools.maven mule-maven-plugin 1.0.0 mysql mysql-connector-java ``` ## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Configuring Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the Bulk Delete Operation This operation enables delete operations to execute at various times using different parameter bindings and a single database statement. 1. Add the **Bulk delete** operation to the canvas. 2. Click the **Bulk delete** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

### Configuring the Bulk Insert Operation This operation enables inserts to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing a single insert operation at various times. 1. Add the **Bulk insert** operation to the canvas. 2. Click the **Bulk insert** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Bulk Update Operation This operation enables updates to execute at various times using different parameter bindings and a single database statement. This improves performance compared to executing one single update operation at various times. 1. Add the **Bulk update** operation to the canvas. 2. Click the **Bulk update** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Delete Operation This operation deletes data in a database. 1. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

2. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Execute DDL Operation This operation allows execution of DDL queries against a database. 1. Add the **Execute DDL** operation to the canvas. 2. Click the **Execute DDL** component on the canvas. 3. In the **General** tab, in **SQL Query Text**, add text for the SQL query to execute. 4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Execute Script Operation This operation executes a SQL script in a single database statement. The script is executed as you provide it, without any parameter binding. 1. Add the **Execute Script** operation to the canvas. 2. Click the **Execute Script** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

SQL Query Text

Text for the SQL query to execute.

No

Script path

Specifies the location of a file to load. The file can point to a resource on the classpath or on a disk.

No

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Insert Operation This operation inserts data into a database. 1. Add the **Insert** operation to the canvas. 2. Click the **Insert** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Query Single Operation This operation selects a single data record from a database. If you provide a SQL query that returns more than one row, only the first record is processed and returned. This operation doesn’t use streaming, which means that immediately after performing the **Query Single** operation, the complete contents of the selected record is loaded into memory. 1. Add the **Query Single** operation to the canvas. 2. Click the **Query Single** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Select Operation This operation queries data from a database. To prevent loading all the results at once, which can lead to performance and memory issues, results are streamed automatically. This means that pages of _fetchSize_ rows are loaded when needed. If this operation is performed inside a transaction (that is, within a **Try** scope component) and that transaction is closed before consuming the data, accessing the results that haven’t been loaded fails. 1. Add the **Select** operation to the canvas. 2. Click the **Select** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Streaming Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See include::connectors::partial$acb-xml-examples.adoc[tag="streaming-strategy"].

No

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Stored Procedure Operation This operation invokes a stored procedure on the database. When the stored procedure returns one or more `ResultSet` instances, results are not read all at once. Instead, results are automatically streamed to prevent performance and memory issues. This behavior means that pages of `_fetchSize_` rows are loaded lazily when needed. If the **Stored procedure** operation is performed inside a transaction (for example, in a **Try** scope component), and that transaction is closed before consuming the data, accessing the results that haven’t been loaded fails. > [!NOTE] Streaming of stored procedure result sets applies only when the JDBC driver supports > multiple open result sets (`DatabaseMetaData#supportsMultipleOpenResults()` returns `true`). If > the driver doesn’t support this capability (for example, the Microsoft SQL Server JDBC driver), > Database Connector reads every result set fully into memory before the operation returns. Large > result sets can cause high memory usage. 1. Add the **Stored Procedure** operation to the canvas. 2. Click the **Stored Procedure** component on the canvas. 3. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

SQL Query Text

Text of the SQL query to execute.

Yes

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

Input-Output Parameters

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Stored Procedure.

No

Output Parameters

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Stored Procedure.

No

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Update Operation This operation updates data in a database. 1. Add the **Update** operation to the canvas. 2. Click the **Update** component on the canvas. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Input Parameters

A map in which keys are the name of an input parameter to set on the JDBC prepared statement. Each parameter must be referenced in the SQL text using a colon prefix, for example, where id = :myParamName. The map’s values contain the actual assignation for each parameter.

No

SQL Query Text

Text of the SQL query to execute.

Yes

4. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Transactional action

The type of joining action that operations can take for transactions:

  • ALWAYS_JOIN

  • JOIN_IF_POSSIBLE (Default)

  • NOT_SUPPORTED

No

Query timeout

Indicates the minimum amount of time before the JDBC driver attempts to cancel a running statement. By default, no timeout (0) is used.

No

Query timeout unit

Select the unit of time to use. The default is SECONDS.

No

Fetch size

Indicates how many rows to fetch from the database when rows are read from a ResultSet. This property is required when streaming is set to true, in which case a default value of 10 is used.

No

Max rows

Sets the limit for the maximum number of rows that any ResultSet object generated by the message processor can contain for the given number. If the limit is exceeded, the excess rows are silently dropped.

No

Parameter types

Array of Parameter Type. Use this parameter to optionally specify the type of (one or more) of the parameters in the query. If a value is provided, you’re not required to reference all of the parameters. You can’t reference a parameter that is not present in the input values.

No

Auto Generate Keys

Indicates when to make auto-generated keys available for retrieval.

No

Auto Generated Keys Column Indexes

List of column indexes that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Auto Generated Keys Column Names

List of column names that indicates which auto-generated keys to make available for retrieval. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Insert.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection Strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

## XML Examples ### Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ### Configuring the Streaming Strategy in XML You can configure how Mule handles streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` ### Configuring the Scheduling Strategy in XML ### Fixed Frequency This is an example of the fixed frequency scheduling strategy XML using the default values: ```xml ``` ### Cron For more complex scheduling strategies, you can use a cron expression: ```xml ``` ## Creating a New Configuration XML File Anypoint Code Builder creates the initial Mule configuration XML file in `src/main/mule` within the Mule project. This file contains global configurations and flow structures. You can create additional configuration files, for example, to store global configurations. To create a new XML configuration file: 1. In the Explorer view, right-click the **mule** folder (`src/main/mule`) and select **New File**. Alternatively, use the menu. Show me how Select the `mule` folder, and then: - In the desktop IDE, select **File** > **New Mule Configuration File**. - In the cloud IDE, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-menu.png) (menu) icon, and select **File** > **New File**. 2. Enter a name for the new file with the `.xml` extension. 3. In the Editor view for the new file, press Ctrl+Space to display available options. 4. Select **Empty mule configuration**: ![New Mule configuration option in auto-correct](/mulesoft/current/en-us/anypoint-code-builder/_images/int-new-mule-config.png) This command adds the following code to the file: ```xml ``` ## See Also - [Anypoint Code Builder Overview](https://docs.mulesoft.com/anypoint-code-builder/) - [Creating Integrations](https://docs.mulesoft.com/anypoint-code-builder/int-create-integrations) - [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb) - [Anypoint Code Builder Components and Commands Reference](https://docs.mulesoft.com/anypoint-code-builder/acb-reference) - [Defining and Securing Properties for a Mule Application](https://docs.mulesoft.com/anypoint-code-builder/int-create-secure-configs) - [Triggering Flows in Your Development Environment](https://docs.mulesoft.com/anypoint-code-builder/int-trigger-flows) - [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components) - [Debugging Mule Applications](https://docs.mulesoft.com/anypoint-code-builder/int-debug-mule-apps) - [Salesforce Help](https://help.salesforce.com) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation) - [Configure Streaming Strategies](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) --- product: Database Connector version: 1.14 --- # Using Anypoint Studio to Configure Database Connector 1.14 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule Project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-input-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If, after reading this topic, you need additional information about the connector fields, see the [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add Database Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and to add the required dependencies to the project’s `pom.xml` file: 1. In the **Mule Palette** view, click **(X) Search in Exchange**. 2. In the **Add Dependencies to Project** window, type `database` in the search field. 3. Click **Database Connector** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these input sources to use with Database Connector: - **Database > On Table Row** Initiates a flow by selecting from a table at a regular interval and generates one message per obtained row - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an **On Table Row** source, follow these steps: 1. In the **Mule Palette** view, select **Database > On Table Row**. 2. Drag **On Table Row** to the Studio canvas. 3. In the **On Table Row** configuration screen, optionally change the value of the **Display Name** field. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **Database Config** window, for **Connection** select any of the connection types to provide to this configuration: - **Data Source Reference Connection** - **Derby Connection** - **Generic Connection** - **Microsoft SQL Server Connection** - **MySQL Connection** - **Oracle Connection** 6. On the **General** tab, specify the database connection information for the connector. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions, when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect with the specified database. 10. Click **OK** to close the window. 11. In the **On Table Row** configuration screen, in **Table**, specify the name of the table to select from. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you immediately define a specific operation for that connector to perform. To add an operation for Database Connector, follow these steps: 1. In the **Mule Palette** view, select **Database Connector** and then select the desired operation. 2. Drag the operation onto the Studio canvas and to the right of the input source. The following screenshot shows the Database Connector operations in the Mule Palette view of Anypoint Studio: ![Database Connector Operations](/mulesoft/current/en-us/db-connector/1.14/_images/database-operations.png) Figure 1. Database Connector Operations ## Configure a Global Element for the Connector When you configure a connector, it’s best to configure a global element that all instances of that connector in the app can use. Database Connector can connect to any database for which a JDBC driver is available. To make it easier to connect to the most popular databases (such as MySQL, Oracle, and Microsoft SQL Server), the connector includes a series of different connection types. To configure the global element for Database Connector, follow these steps: 1. Select the operation in the Studio canvas. 2. In the configuration screen for the operation, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 3. In the **Database Config** window, for **Connection** select any of the connection types to provide to this configuration: - **Data Source Reference Connection** - **Derby Connection** - **Generic Connection** - **Microsoft SQL Server Connection** - **MySQL Connection** - **Oracle Connection** 4. On the **General** tab, specify the database connection information for the connector. 5. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions, when connecting to the database. 6. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 7. Click **Test Connection** to confirm that Mule can connect with the specified database. 8. Click **OK**. The following screenshot shows the Database Connector **Global Element Configuration** window in Anypoint Studio: ![Database Connector Global Element Configuration](/mulesoft/current/en-us/db-connector/1.14/_images/database-global-configuration.png) Figure 2. Database Connector Global Element Configuration ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the output is visible in the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log is visible in your OS console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also view the app log in the default location `MULE_HOME/logs/.log`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.14/database-documentation) - [Configure Driver Visibility using Mule Maven Plugin](https://docs.mulesoft.com/db-connector/1.14/database-connector-driver-configuration) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.15 --- # Using Anypoint Studio to Configure Database Connector 1.15 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule Project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-input-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If, after reading this topic, you need additional information about the connector fields, see the [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add Database Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and to add the required dependencies to the project’s `pom.xml` file: 1. In the **Mule Palette** view, click **(X) Search in Exchange**. 2. In the **Add Dependencies to Project** window, type `database` in the search field. 3. Click **Database Connector** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these input sources to use with Database Connector: - **Database > On Table Row** Initiates a flow by selecting from a table at a regular interval and generates one message per obtained row - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an **On Table Row** source, follow these steps: 1. In the **Mule Palette** view, select **Database > On Table Row**. 2. Drag **On Table Row** to the Studio canvas. 3. In the **On Table Row** configuration screen, optionally change the value of the **Display Name** field. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **Database Config** window, for **Connection** select any of the connection types to provide to this configuration: - **Data Source Reference Connection** - **Derby Connection** - **Generic Connection** - **Microsoft SQL Server Connection** - **MySQL Connection** - **Oracle Connection** 6. On the **General** tab, specify the database connection information for the connector. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions, when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect with the specified database. 10. Click **OK** to close the window. 11. In the **On Table Row** configuration screen, in **Table**, specify the name of the table to select from. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you immediately define a specific operation for that connector to perform. To add an operation for Database Connector, follow these steps: 1. In the **Mule Palette** view, select **Database Connector** and then select the desired operation. 2. Drag the operation onto the Studio canvas and to the right of the input source. The following screenshot shows the Database Connector operations in the Mule Palette view of Anypoint Studio: ![Database Connector Operations](/mulesoft/current/en-us/db-connector/1.15/_images/database-operations.png) Figure 1. Database Connector Operations ## Configure a Global Element for the Connector When you configure a connector, it’s best to configure a global element that all instances of that connector in the app can use. Database Connector can connect to any database for which a JDBC driver is available. To make it easier to connect to the most popular databases (such as MySQL, Oracle, and Microsoft SQL Server), the connector includes a series of different connection types. To configure the global element for Database Connector, follow these steps: 1. Select the operation in the Studio canvas. 2. In the configuration screen for the operation, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 3. In the **Database Config** window, for **Connection** select any of the connection types to provide to this configuration: - **Data Source Reference Connection** - **Derby Connection** - **Generic Connection** - **Microsoft SQL Server Connection** - **MySQL Connection** - **Oracle Connection** 4. On the **General** tab, specify the database connection information for the connector. 5. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions, when connecting to the database. 6. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 7. Click **Test Connection** to confirm that Mule can connect with the specified database. 8. Click **OK**. The following screenshot shows the Database Connector **Global Element Configuration** window in Anypoint Studio: ![Database Connector Global Element Configuration](/mulesoft/current/en-us/db-connector/1.15/_images/database-global-configuration.png) Figure 2. Database Connector Global Element Configuration ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the output is visible in the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log is visible in your OS console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also view the app log in the default location `MULE_HOME/logs/.log`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/1.15/database-documentation) - [Configure Driver Visibility using Mule Maven Plugin](https://docs.mulesoft.com/db-connector/1.15/database-connector-driver-configuration) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.16 is-latest-version: true --- # Using Anypoint Studio to Configure Database Connector 1.16 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule Project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-input-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If, after reading this topic, you need additional information about the connector fields, see the [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add Database Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and to add the required dependencies to the project’s `pom.xml` file: 1. In the **Mule Palette** view, click **(X) Search in Exchange**. 2. In the **Add Dependencies to Project** window, type `database` in the search field. 3. Click **Database Connector** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these input sources to use with Database Connector: - **Database > On Table Row** Initiates a flow by selecting from a table at a regular interval and generates one message per obtained row - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an **On Table Row** source, follow these steps: 1. In the **Mule Palette** view, select **Database > On Table Row**. 2. Drag **On Table Row** to the Studio canvas. 3. In the **On Table Row** configuration screen, optionally change the value of the **Display Name** field. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **Database Config** window, for **Connection** select any of the connection types to provide to this configuration: - **Data Source Reference Connection** - **Derby Connection** - **Generic Connection** - **Microsoft SQL Server Connection** - **MySQL Connection** - **Oracle Connection** 6. On the **General** tab, specify the database connection information for the connector. 7. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions, when connecting to the database. 8. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect with the specified database. 10. Click **OK** to close the window. 11. In the **On Table Row** configuration screen, in **Table**, specify the name of the table to select from. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you immediately define a specific operation for that connector to perform. To add an operation for Database Connector, follow these steps: 1. In the **Mule Palette** view, select **Database Connector** and then select the desired operation. 2. Drag the operation onto the Studio canvas and to the right of the input source. The following screenshot shows the Database Connector operations in the Mule Palette view of Anypoint Studio: ![Database Connector Operations](/mulesoft/current/en-us/db-connector/latest/_images/database-operations.png) Figure 1. Database Connector Operations ## Configure a Global Element for the Connector When you configure a connector, it’s best to configure a global element that all instances of that connector in the app can use. Database Connector can connect to any database for which a JDBC driver is available. To make it easier to connect to the most popular databases (such as MySQL, Oracle, and Microsoft SQL Server), the connector includes a series of different connection types. To configure the global element for Database Connector, follow these steps: 1. Select the operation in the Studio canvas. 2. In the configuration screen for the operation, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 3. In the **Database Config** window, for **Connection** select any of the connection types to provide to this configuration: - **Data Source Reference Connection** - **Derby Connection** - **Generic Connection** - **Microsoft SQL Server Connection** - **MySQL Connection** - **Oracle Connection** 4. On the **General** tab, specify the database connection information for the connector. 5. On the **Transactions** tab, optionally specify the transaction isolation, or XA transactions, when connecting to the database. 6. On the **Advanced** tab, optionally specify connection pooling and reconnection information, including a reconnection strategy. 7. Click **Test Connection** to confirm that Mule can connect with the specified database. 8. Click **OK**. The following screenshot shows the Database Connector **Global Element Configuration** window in Anypoint Studio: ![Database Connector Global Element Configuration](/mulesoft/current/en-us/db-connector/latest/_images/database-global-configuration.png) Figure 2. Database Connector Global Element Configuration ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the output is visible in the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log is visible in your OS console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also view the app log in the default location `MULE_HOME/logs/.log`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [Database Connector Reference](https://docs.mulesoft.com/db-connector/latest/database-documentation) - [Configure Driver Visibility using Mule Maven Plugin](https://docs.mulesoft.com/db-connector/latest/database-connector-driver-configuration) - [Salesforce Help](https://help.salesforce.com) --- product: Database Connector version: 1.14 --- # Using XA Transactions in Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) provides the option to use Extended Architecture Transactions (XA Transactions) when you enable the **Use XA Transactions** field in the Database Connector global configuration. ## Before You Begin Before getting started, ensure that you have an understanding of [XA Transactions](https://docs.mulesoft.com/mule-runtime/latest/xa-transactions) ## Use XA Transactions You can enable the **Use XA Transactions** field in the database global connector configuration for the **Derby Connection**, **Generic Connection**, **Microsoft SQL Server Connection**, **MySQL Connection**, and **Oracle Connection**. For a **Data Source Reference Connection**, refer to the [Configure a Data Source Reference Connection When in XA Transaction Mode](https://docs.mulesoft.com/db-connector/1.14/database-connector-connection#data-source-connection-xa) topic. > [!NOTE] When you enable **Use XA Transactions** the connection pooling is created as well. The following example shows how to configure **Use XA Transactions** for the **MySQL Connection** in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the search bar, type `database`. 4. Select **Database Config**. 5. Click **OK**. 6. In the **Global Element Properties** window, select **MySQL Connection** in the **Connection** field. 7. Select the **Transactions** tab. 8. Select **Use XA Transactions**, which indicates that the created data source must support XA transactions. Note that the implementation creates an Enhydra XADatasource. 9. Configure other required database configurations in the **General** and **Advanced** tabs. 10. Click **OK**. ![Use XA Transactions field selected](/mulesoft/current/en-us/db-connector/1.14/_images/database-connector-xatransactions.png) In the **Configuration XML** editor window, the configuration looks like this: ```xml ``` ## See Also - [Configuring the Bitronix Transaction Manager](https://docs.mulesoft.com/mule-runtime/latest/using-bitronix-to-manage-transactions#configuring-the-bitronix-transaction-manager) --- product: Database Connector version: 1.15 --- # Using XA Transactions in Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) provides the option to use Extended Architecture Transactions (XA Transactions) when you enable the **Use XA Transactions** field in the Database Connector global configuration. ## Before You Begin Before getting started, ensure that you have an understanding of [XA Transactions](https://docs.mulesoft.com/mule-runtime/latest/xa-transactions) ## Use XA Transactions You can enable the **Use XA Transactions** field in the database global connector configuration for the **Derby Connection**, **Generic Connection**, **Microsoft SQL Server Connection**, **MySQL Connection**, and **Oracle Connection**. For a **Data Source Reference Connection**, refer to the [Configure a Data Source Reference Connection When in XA Transaction Mode](https://docs.mulesoft.com/db-connector/1.15/database-connector-connection#data-source-connection-xa) topic. > [!NOTE] When you enable **Use XA Transactions** the connection pooling is created as well. The following example shows how to configure **Use XA Transactions** for the **MySQL Connection** in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the search bar, type `database`. 4. Select **Database Config**. 5. Click **OK**. 6. In the **Global Element Properties** window, select **MySQL Connection** in the **Connection** field. 7. Select the **Transactions** tab. 8. Select **Use XA Transactions**, which indicates that the created data source must support XA transactions. Note that the implementation creates an Enhydra XADatasource. 9. Configure other required database configurations in the **General** and **Advanced** tabs. 10. Click **OK**. ![Use XA Transactions field selected](/mulesoft/current/en-us/db-connector/1.15/_images/database-connector-xatransactions.png) In the **Configuration XML** editor window, the configuration looks like this: ```xml ``` ## See Also - [Configuring the Bitronix Transaction Manager](https://docs.mulesoft.com/mule-runtime/latest/using-bitronix-to-manage-transactions#configuring-the-bitronix-transaction-manager) --- product: Database Connector version: 1.16 is-latest-version: true --- # Using XA Transactions in Database Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Database (Database Connector) provides the option to use Extended Architecture Transactions (XA Transactions) when you enable the **Use XA Transactions** field in the Database Connector global configuration. ## Before You Begin Before getting started, ensure that you have an understanding of [XA Transactions](https://docs.mulesoft.com/mule-runtime/latest/xa-transactions) ## Use XA Transactions You can enable the **Use XA Transactions** field in the database global connector configuration for the **Derby Connection**, **Generic Connection**, **Microsoft SQL Server Connection**, **MySQL Connection**, and **Oracle Connection**. For a **Data Source Reference Connection**, refer to the [Configure a Data Source Reference Connection When in XA Transaction Mode](https://docs.mulesoft.com/db-connector/latest/database-connector-connection#data-source-connection-xa) topic. > [!NOTE] When you enable **Use XA Transactions** the connection pooling is created as well. The following example shows how to configure **Use XA Transactions** for the **MySQL Connection** in Anypoint Studio: 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. In the search bar, type `database`. 4. Select **Database Config**. 5. Click **OK**. 6. In the **Global Element Properties** window, select **MySQL Connection** in the **Connection** field. 7. Select the **Transactions** tab. 8. Select **Use XA Transactions**, which indicates that the created data source must support XA transactions. Note that the implementation creates an Enhydra XADatasource. 9. Configure other required database configurations in the **General** and **Advanced** tabs. 10. Click **OK**. ![Use XA Transactions field selected](/mulesoft/current/en-us/db-connector/latest/_images/database-connector-xatransactions.png) In the **Configuration XML** editor window, the configuration looks like this: ```xml ``` ## See Also - [Configuring the Bitronix Transaction Manager](https://docs.mulesoft.com/mule-runtime/latest/using-bitronix-to-manage-transactions#configuring-the-bitronix-transaction-manager)