Connect to your data with Ballerina

Anupama Pathirage
Ballerina Swan Lake Tech Blog
3 min readJul 8, 2018

Data integration is a complex problem that must be solved by any organization. Nowadays data is flowing to and from many directions via different sources such as databases, the cloud, legacy systems, ERPs, on-premise applications, etc. Data is one of most valuable assets for any organization and data integration allows businesses to combine data residing in different sources to provide users consolidated view.

Why Ballerina?

Ballerina is a concurrent, transactional, statically typed programming language [1] .Ballerina facilitate easy integration of your data which resides in different data sources.

Rich Set of connectors

Ballerina has rich set of client endpoints which can be used to connect different data sources.

JDBC Client

Ballerina JDBC client can connect almost any Java Database Connectivity (JDBC) relational database and run SQL operations for them. After connecting with the database JDBC client can be used to execute SQL data definition statements and data manipulation statements. Following operations are supported by the JDBC client.

  • select
  • update
  • updateWithGeneratedKeys
  • call
  • batchUpdate
  • getProxyTable

More details of JDBC client can be found in previous blog posts on Ballerina JDBC Client — Connecting to DB and Ballerina JDBC Client — Performing DB Operations. Also Ballerina JDBC client example gives a complete example on JDBC client usage.

MySQL Client

Ballerina MySQL client is used to interact with MySQL database. The supported operations are similar to the JDBC client. Only difference is with the client configuration.

Ballering MySQL client example gives more details on the usage.

H2 Client

Ballerina H2 client is used to interact with H2 database. Like in MySQL client, the supported operations are similar to the JDBC client. Only difference is with the client configuration.

Ballerina H2 client example gives more details on the usage.

MongoDB Client

Ballerina MongoDB Client Endpoint is used to connect Ballerina with MongoDB data source. With the Ballerina MongoDB client endpoint following actions are supported.

  • insert — To insert document to a given collection
  • find — To select document from a given collection according to given query.
  • findOne — To select the first document match with the query.
  • update — To update documents that matches to the given filter.
  • delete — To delete documents that matches to the given filter.

Ballerina MongoDB client releases can be found in package repository.

Cassandra Client

Ballerina Cassandra Client Endpoint is used to connect Ballerina with Cassandra data source. With the Ballerina Cassandra client endpoint following actions are supported.

  • update — To execute a data or schema update query
  • select — To select data from the datasource
  • close — To close the cassandra connection.

Ballerina Cassandra client releases can be found in package repository.

Redis Client

Ballerina Redis Connector is used to connect Ballerina with a Redis data source. With the Ballerina Redis Connector following operations are supported.

  • Basic Commands like AUTH, ECHO, PING, QUIT
  • String commands
  • List Commands
  • Set Commands
  • Sorted Set Commands
  • Hash Commands
  • Key Commands

Design View

Ballerina provides both textual syntax and corresponding graphical syntax for any program. An entire Ballerina program can be viewed as a collection of sequence diagrams that interact with each other. This gives a better view and understand on the integration scenario and database endpoints are represented as actors of the sequence diagram.

Open Source

Ballerina is an open-source project under Apache 2.0 license and is developed by the Ballerina community. So you can go ahead and try out ballerina features at zero cost :)

[1] https://ballerina.io/

--

--

Anupama Pathirage
Ballerina Swan Lake Tech Blog

Open Source Contributor | Developer — Ballerina Language| Director of Engineering — WSO2 | Travel 🏝 . Photography 📸 | 🇱🇰 | Twitter: https://bit.ly/356icnr