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
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
View Events Video Library
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

Migrate, Modernize and Build Java Web Apps on Azure: This live workshop will cover methods to enhance Java application development workflow.

Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.

Kubernetes in the Enterprise: The latest expert insights on scaling, serverless, Kubernetes-powered AI, cluster security, FinOps, and more.

E-Commerce Development Essentials: Considering starting or working on an e-commerce business? Learn how to create a backend that scales.

Related

  • REST API Microservice AI Design and Spreadsheet Rules
  • Finding the Right Database Solution: A Comprehensive Comparison of AWS RDS MySQL and Aurora MySQL
  • An In-Depth Look at Oracle MySQL HeatWave
  • SQL Query Performance Tuning in MySQL

Trending

  • Virtual Threads: A Definite Advantage
  • Enhancing Observability With AI/ML
  • Top 10 Software Architecture Patterns to Follow in 2024
  • A Comprehensive Guide to Cloud Monitoring Tools: Ensuring Optimal Performance and Security
  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
29.4K 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

  • REST API Microservice AI Design and Spreadsheet Rules
  • Finding the Right Database Solution: A Comprehensive Comparison of AWS RDS MySQL and Aurora MySQL
  • An In-Depth Look at Oracle MySQL HeatWave
  • SQL Query Performance Tuning in MySQL

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
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: