mule Connection to MySQL Database Using Anypoint Studio (Mule) Example to retrieve Rows from Table in MySQL


Required External Jar: mysql-connector-java-5.1.40-bin.jar to connect to Data Base. Add this jar by right clicking the project -->Build Path--> Add external Archieve. Create the Flow as Flowing

enter image description here

2) Database Connector Configuration: Select MySQL as your database by double clicking the Database connector and fill all the details as mentioned. After that Click Test Connection which will give Connection Successfull...

In Query: Select * from where test is my schema and Contact is my table name.

enter image description here

3)Object to JSON: Drag Object to JSON connector and leave it as it is without any modifications.

4)Set Payload: Drag the Set Payload connector and set the value attribute to #[payload]

enter image description here Final Step: Deploye the code and run as http://localhost:8089/test

8089 is my port number.. whatever yours u need to give that.

When you run you can see the following output in Json Format