mule Select Rows from MySQL Data Base in Anypoint Studio(Mule)


Example

Step1 Message Flow: [![enter image description here][1]][1]

Step 2: Databse Connector Configuration

For this you need mysql-connector-java-5.1.40-bin.jar . Right click on Project -->build Path--> Add external archieve and add the jar(without jar it cannot be connected) Enter all the values correctly mentioned below screenshot. Then Click Test connection and should show connection successful

Query: select * from test.contact

where test =Schema name or database name and contact is table name. [![enter image description here][2]][2]

3) XML view

Use Object to JSON connector and leave the fields as it is

Use setpayload connector and enter the VALUE attribute as #[payload]

[![enter image description here][3]][3]

Final Step: Deploye the project , run as mule application. After running.. run the url either in POSTMAN or Chrome. http://localhost:8089/test

8089 is my local port. Whatever u mention run with that port.

[![enter image description here][4]][4]

Finally the Values are displayed in JSON format. Try to run Different Queries.

Am new to Mule. Found informative and posting it. [1]: https://i.stack.imgur.com/jt4tS.png [2]: https://i.stack.imgur.com/oNQJe.png [3]: https://i.stack.imgur.com/EI7U4.png [4]: https://i.stack.imgur.com/taq6z.png