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 Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  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.

Ramesh Mandali user avatar by
Ramesh Mandali
·
Aug. 06, 18 · Tutorial
Like (3)
Save
Tweet
Share
27.57K 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.

Popular on DZone

  • Select ChatGPT From SQL? You Bet!
  • Mind Map Reuse in Software Groups
  • Top 5 Java REST API Frameworks
  • How To Create and Edit Excel XLSX Documents in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: