Skip to main content

Overview

MySQL is one of the world's most popular open-source relational database management systems. The ballerinax/mysql connector (v1.18.0) provides programmatic access to MySQL databases through the standard SQL interface. It supports queries, inserts, updates, deletes, batch operations, stored procedure calls, and real-time Change Data Capture (CDC) via a Debezium-based listener.

Key features​

  • Full SQL operations: query, insert, update, delete using parameterized queries for safety and convenience
  • Single-row retrieval via queryRow for lookups, aggregations, and existence checks
  • Batch execution support for inserting or modifying multiple rows in a single operation
  • Stored procedure invocation with IN, OUT, and INOUT parameter support and multiple result sets
  • Change Data Capture (CDC) listener powered by Debezium for real-time onRead, onCreate, onUpdate, onDelete, and onError events
  • Flexible connection pooling: global shared, client-owned, or local shared pools
  • SSL/TLS support with configurable modes: Disabled, Preferred, Required, Verify CA, and Verify Identity
  • GraalVM native image support when used with ballerinax/mysql.driver

Actions​

Actions are operations you invoke on a MySQL database from your integration, such as executing SQL queries, inserting or updating records, running batch operations, and calling stored procedures. The MySQL connector exposes actions through a single client:

ClientActions
ClientSQL queries, single-row retrieval, DML/DDL execution, batch operations, stored procedure calls, connection management

See the Action Reference for the full list of operations, parameters, and sample code for each client.

Triggers​

Triggers allow your integration to react to data changes happening in a MySQL database in real time. The connector uses Debezium-based Change Data Capture (CDC) to stream row-level change events to a mysql:CdcListener, which invokes your service callbacks automatically.

Supported trigger events:

EventCallbackDescription
Record read (snapshot)onReadFired during the initial snapshot when existing rows are read from the database.
Record createdonCreateFired when a new row is inserted into a monitored table.
Record updatedonUpdateFired when an existing row is modified in a monitored table.
Record deletedonDeleteFired when a row is deleted from a monitored table.
Listener erroronErrorFired when the listener encounters an error during change-event delivery (for example, deserialization failures or connector errors).

See the Trigger Reference for listener configuration, service callbacks, and the row record passed to each callback.

Documentation​

  • Setup Guide: Walks you through setting up a MySQL database and obtaining the connection credentials required to use the MySQL connector.

  • Action Reference: Full reference for all clients: operations, parameters, return types, and sample code.

  • Trigger Reference: Reference for event-driven integration using the listener and service model.

  • Example: Learn how to build and configure an integration using the MySQL connector, including connection setup and operation configuration. For the listener and service model, see Trigger Reference.

How to contribute​

As an open source project, WSO2 welcomes contributions from the community.

To contribute to the code for this connector, please create a pull request in the following repository.

Check the issue tracker for open issues that interest you. We look forward to receiving your contributions.