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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Database Bottlenecks Nobody Talks About: Optimizing SQL Queries Beyond Indexing
  • LangChain With SQL Databases: Natural Language to SQL Queries
  • 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

Trending

  • Java 8 Optional - Avoid Null and NullPointerException Altogether - and Keep It Pretty
  • Who Should Grade Your AI? Rules vs LLM Judges vs Humans
  • Replay, Scheduling, and Throttling: Engineering a Self-Service Kafka Streaming Tool at Scale
  • Putting Guardrails Around What Your AI Agent Is Allowed to Touch

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Aug. 06, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
31.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • Database Bottlenecks Nobody Talks About: Optimizing SQL Queries Beyond Indexing
  • LangChain With SQL Databases: Natural Language to SQL Queries
  • 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

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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