DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Custom Model Context Protocol (MCP) for NL2SQL: A Rigorous Evaluation Framework on Oracle Database
  • Using Arrow Flight SQL to Improve Data Transfer Performance in Apache Doris
  • Automating a Web Form With Playwright MCP and MySQL MCP
  • Master SQL Performance Optimization: Step-by-Step Techniques With Case Studies

Trending

  • Liquid Glass, Material 3, and a Lot of Plumbing
  • Good Data, Bad Metric: A Mutation Testing Pattern for Analytics Engineering
  • Prompt Injection Is Real, So I Built a Python Firewall for LLM Pipelines
  • How to Save Money Using Custom LLMs for Specific Tasks
  1. DZone
  2. Data Engineering
  3. Databases
  4. MySQL Database SELECT Query Operation in Mule 4

MySQL Database SELECT Query Operation in Mule 4

Let's look at a brief tutorial that explains how to do a MySQL database SELECT query operation in Mule 4.

By 
Ramesh Mandali user avatar
Ramesh Mandali
·
Aug. 06, 18 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
31.6K Views

Join the DZone community and get the full member experience.

Join For Free

Step1: Select Mule project from Anypoint studio and write the project name. Then click ok.

Step2: Drag and drop HTTP listener, database select and to track the logs logger component from Mule palette.

Step3: For database, we need to configure jar for specific database which we are using in my case I am using MySQL database so here the jar is MYSQL JDBC driver and provide the hostname, port number, username, password, and database name.

Step4: Here we need to add the Maven dependency or jar from local if jar downloaded screen looks like the below.

Step5: If everything is ok that you provided in the configuration, then after hit test connection, you will see the message as test connection successful on the screen if the configuration is ok.

Step6: In SQL query text, we must write the query base on our requirement.

Step7: After that, you can deploy your application by right click on the flow and Run project databaseSelect.then you will see in console as DEPLOYED status.

Step8: Check your application is running as expected from Postman.

Code snippet:

<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="52d3f07a-bc3e-46dc-aed9-4841a2fd17d9" >
<http:listener-connection host="0.0.0.0" port="8087" />
</http:listener-config>
<db:config name="Database_Config" doc:name="Database Config" doc:id="026a0de2-242a-40c9-a9c6-955003c6b491" >
<db:my-sql-connection host="localhost" port="3306" user="root" password="root" database="world" />
</db:config>
<flow name="databaseinsertFlow" doc:id="272ead75-2085-4b72-8664-6462fd1d361e" >
<http:listener doc:name="select" doc:id="8012f0b7-3282-408f-bce8-21ae1d5b94e5" config-ref="HTTP_Listener_config" path="/select">
<ee:repeatable-file-store-stream />
<http:response >
<http:body ><![CDATA[#[output application/json --- payload]]]></http:body>
</http:response>
</http:listener>
<db:select doc:name="Select" doc:id="be31b9b5-a7bd-42ef-b2ac-ce9a109983d1" config-ref="Database_Config">
<ee:repeatable-file-store-iterable />
<db:sql >select name,IndepYear from country</db:sql>
</db:select>
<logger level="INFO" doc:name="Logger" doc:id="3e7529b7-7523-48ac-97e6-256f7d7e6c5d" />
</flow>
</mule>

Thank you.

Database MySQL

Opinions expressed by DZone contributors are their own.

Related

  • Custom Model Context Protocol (MCP) for NL2SQL: A Rigorous Evaluation Framework on Oracle Database
  • Using Arrow Flight SQL to Improve Data Transfer Performance in Apache Doris
  • Automating a Web Form With Playwright MCP and MySQL MCP
  • Master SQL Performance Optimization: Step-by-Step Techniques With Case Studies

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook