Mule ESB
How to connect to a MySql Database
Let’s assume you have a fully configured MySql instance in local environment, and you can
access to phpmyadmin administration tool.
As a first step, we begin creating a new Database called mule_test:
Click on create and go to next page
Now let’s create a table named User, and populate it as follows with some sample data:
It’s time now to populate the table with some data:
Let’s dive now in Anypoint Studio and create a new Mule Project, with an empty flow
Called db_testFlow
Let’s configure an http inbound endpoint on localhost:8081/dbTest:
Now we can insert the db component that will get the users inserted in
previous page.
But first of all we have to add the mysql jar client on the buildpath of the
project:
Now we can create the connector configuration
Finally we can create the query that get the results printing them on the console
with the logger component:
[[db_test].HTTP_Listener_Configuration.worker.0
1]
org.mule.api.processor.LoggerMessageProcessor:
[{surname=Smith, profession=programmer,
iduser=1, name=Dan}, {surname=Khedira,
profession=football player, iduser=2,
name=Sami}, {surname=Simel, profession=actor,
iduser=3, name=Rob}] Enjoy with the MULE!

Mule esb db_1

  • 1.
    Mule ESB How toconnect to a MySql Database
  • 2.
    Let’s assume youhave a fully configured MySql instance in local environment, and you can access to phpmyadmin administration tool. As a first step, we begin creating a new Database called mule_test: Click on create and go to next page
  • 3.
    Now let’s createa table named User, and populate it as follows with some sample data:
  • 4.
    It’s time nowto populate the table with some data:
  • 5.
    Let’s dive nowin Anypoint Studio and create a new Mule Project, with an empty flow Called db_testFlow Let’s configure an http inbound endpoint on localhost:8081/dbTest: Now we can insert the db component that will get the users inserted in previous page. But first of all we have to add the mysql jar client on the buildpath of the project:
  • 6.
    Now we cancreate the connector configuration
  • 7.
    Finally we cancreate the query that get the results printing them on the console with the logger component: [[db_test].HTTP_Listener_Configuration.worker.0 1] org.mule.api.processor.LoggerMessageProcessor: [{surname=Smith, profession=programmer, iduser=1, name=Dan}, {surname=Khedira, profession=football player, iduser=2, name=Sami}, {surname=Simel, profession=actor, iduser=3, name=Rob}] Enjoy with the MULE!