How to establish a DB connection between Mulesoft and AS400

Posted by

How to establish a DB connection between Mulesoft and AS400

If you are wondering how to establish a DB connection between Mulesoft and AS400, you're not alone! This article will show you how to properly configure a database connection between an AS400 system and a Mulesoft application.

Nowadays, databases are driven by many many many… We've got a considerable abundance of many drivers and systems. You might be stuck in a project wondering to reach out to a database under an AS400 system. Don't worry: Mulesoft can establish a proper DB connection with AS400 via a native database connector.

Before we begin, let me introduce myself.

My name is Lorenzo Neri, a Cap4 Lab integration engineer. Several times during my working time, I met many different problems I tried to solve, then afterward, a question came to my mind: "What if I bring help to other people to solve my same problem?".

How to establish an AS400 DB connection with Mulesoft native database connector

As you read two paragraphs behind, you needn't re-invent the wheel: Mulesoft gives us what you need, partially.

Starting from scratch, what do you need is to create a flow adding a database operation: to keep it simple, I'll use a "SELECT" like so:

 

Once you build the flow, you'll have to configure the SELECT operation into the connector.

This won't be enough! Yep, you got it: you need to create and set a proper connector configuration for the connector itself.

To do so, you need to create a Database Configuration and the proper driver for the AS400 system.

The driver you'll need is JT400 which can be directly downloaded from MVNRepository with a click here.

Once you have downloaded it, or if you prefer to add the Maven dependency via XML, you can proceed to configure the database connection. It will be like so:

  • Connection: Generic Connection

  • JDBC Driver: you could add the "jt400.jar" as a "local file" directly; otherwise, the Maven XML as "Maven dependency."

  • Driver class name: independently of your JDBC Driver choice, the driver class name you'll need to establish a proper connection with the AS400 database is "com.ibm.as400.access.AS400JDBCDriver"

 

To conclude your database configuration, you'll need your username and related password, the database you're after to operate with, in conclusion, a properly formatted URL.

How is composed the AS400 JDBC database connection URL

According to the official AS400 guide, the JDBC database connection URL for AS400 systems is as follows:

jdbc:as400://YOUR_AS400_SERVER_IP/THE_DATABASE_NAME;user=YOUR_USERNAME;password=YOUR_PASSWORD

 Finally, to establish a DB connection between Mulesoft and AS400, your database configuration should look like this:

If you run your Mule application and execute the SELECT connector successfully, you should get back a Java typed payload containing the query's result: