Command-line SQL Client for IBM i 7.x (AS/400)

In the category of “niche blogposts”, this is probably the “nichest”. But it might be useful, so I’ll share it.

Recently I had to interface an IBM i system (think “mainframe”, though not exactly) from a command-line-only Linux environment. The interesting part is that you can access the IBM i files through SQL syntax, as they are tabular in nature. However, I failed to find a proper tool for that. There are UI tools by IBM but they don’t work in a headless environment.

So I decided to write my own simple tool – a command line SQL client for IBM i 7.x. It relies on an IBM-provided library (which, by the way, fails in some cases in headless environments as well, as it tries to prompt for certain data using awt/swing). The tool can be used after building it with maven and by simply executing SQL queries after connecting:

java -jar as400-sql-client.jar <connectionString> <username> <password>

It can be can be fond here. Apart from being useful in navigating the IBM system, it relies in the jline project which allows you to create rich command line tools that support autocomplete, history, coloring, etc.

I hope that nobody will need this tool, but in the rare case that someone does need it, I hope to save them hours of struggle.

2 thoughts on “Command-line SQL Client for IBM i 7.x (AS/400)”

  1. Is it a wrapper over a standart JT400.jar functions? Or why can not we use a standard iSeries Navigator software which actually contains run query tool?

  2. Yes, it is a wrapper.
    All tools I found required UI. Even the JT400 is written assuming an X environment, and I had to catch odd JWT exceptions.

    Maybe I missed some tool in the toolbox – if there’s one that works well, please share a link.

Leave a Reply

Your email address will not be published. Required fields are marked *