Execute DDL Statement in MySQL

 

Let’s see how we can Execute DDL Statement in MySQL using the DB connector in MuleSoft.

Create a project in Anypoint Studio

Execute DDL Statement in MySQL

 

Add the HTTP listener and flow to get the request for executing DDL statement

Execute DDL Statement in MySQL

 

Drag and Drop Execute DDL activity in a flow

Execute DDL Statement in MySQL

 

Create a MySQL connection by following the steps mentioned in the Connect with MySQL DB through MuleSoft

 

Paste the required DDL in SQL Query Text – Remove the semicolon from the DDL statement

Example DDL

CREATE TABLE inventory (
    id INT PRIMARY KEY,
    product VARCHAR(50) UNIQUE,
    quantity INT,
    price DECIMAL(18,2)
)

Note – you can only provide the plain text as an input here and it can’t be changed to dynamic content e.g. getting the statement from the input payload

 

Set the response payload

 

Run the service

 

Test the endpoint in a browser

http://localhost:8081/execute-ddl

 

We can see the table in MySQL database

 

Sample Application – mysql-db-service

Sample SOAP UI project – MySQL-service-soapui-project

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments