Support for MySQL is now available in IBM App Connect. MySQL is an open source relational database management system, which is based on Structured Query Language (SQL).
Requirements for connecting to MySQL
To see which events and actions are available for MySQL and use them in your flows, you must connect App Connect to your MySQL database server by setting up an account with the following connection details: the MySQL database host and port, a valid MySQL user name and password, and the database name. Connection to the IBM Secure Gateway is also required in instances where MySQL database servers run on-premises.
- The MySQL user credentials that you specify must have permission to create, retrieve, and update (INSERT, SELECT, and UPDATE)) rows/records in tables and views in the database.
- In the mysql.user table, there must be a
User entry for the host where the IBM Secure Gateway Client is installed, and the MySQL user name used for the App Connect connection.
You can integrate MySQL with any of the other applications or APIs in the App Connect catalog, as required for your use case. To illustrate how easy it can be to set up a flow, we are going to describe a data sync scenario that enables us to create a corresponding contact record in our MySQL database for every new contact that is added to Salesforce.
Let’s suppose we use Salesforce to manage contacts and use a MySQL database table named Contact to store contact information. The Contact table includes a CONTACTID column, which is defined as the primary key and which helps us link contact records in the two applications.
We start our event-driven flow by adding a Salesforce “New contact” event as the trigger for the flow. (If not already connected, we can add an account as described in How to use IBM App Connect with Salesforce.)
Then, we add a MySQL “Create record” action. The action syncs the data across the two apps by inserting a row in the MySQL Contact database table whenever a Salesforce contact is created.
To ensure that we copy the correct data across, we use the mapping function to populate the MySQL fields dynamically with data from Salesforce. We map the first name, last name, phone, email, and birth date recorded in Salesforce to the corresponding columns in the MySQL Contact table. We also map the contact ID that Salesforce generates for a new contact to the CONTACTID MySQL column.
That’s all that’s needed for our flow! We can start the flow and then test it as follows to make sure the data sync works as expected:
- Log in to the Salesforce instance using the same account details that were used to set up the Salesforce account in App Connect.
- Create and save a Salesforce contact.
- Log in to the MySQL database server and run a query on the Contact table to verify you can see the contact that was added to Salesforce.
- Finally, return to the App Connect dashboard and locate the tile for our flow. Notice that the flow tile shows a green tick to indicate that the flow ran successfully.