Search code examples
db2ibm-midrangeflyway

Is there a way to use Flyway on AS400?


I need to implement migration tool like Flyway in order to use Jenkins to deploy DB changes. I tried to add jt400.jar file and added configuration as follows:

flyway.url=jdbc:as400://192.168.171.251:446/DBDEV
flyway.driver=com.ibm.as400.access.AS400JDBCDriver

as a driver and it would not connect with this message:

ERROR: No database found to handle jdbc:as400://192.168.171.251:446/DBDEV

I also tried with using IBM DB2 driver and had configuration

flyway.url=jdbc:db2://192.168.171.251:50000/DBDEV
flyway.driver=com.ibm.db2.jcc.DB2Driver

this time I am getting this kind of refusal message

ERROR: 
Unable to obtain connection from database (jdbc:db2://192.168.171.251:50000/DBDEV) for user 'DEVUSER': 
[jcc][t4][2043][11550][4.26.14] Exception java.net.ConnectException: Error opening socket to server
 /192.168.171.251 on port 50,000 with message: Connection refused (Connection refused). 
ERRORCODE=-4499, SQLSTATE=08001

With this test migration I am trying to create a simple table by executing this sql

CREATE TABLE PERSON (
    ID INT NOT NULL,
    NAME VARCHAR(100) NOT NULL
);

Anyone had this situation and solved it?


Solution

  • I believe that at present there is no support for flyway to work with IBM i (as/400) regardless of whether you use jt400.jar or an IBM jdbc driver.

    You can either use a different database-schema versioning tool, or find a fork of flyway that supports i-series (or pay someone to create and support such a fork, it is open source...).

    It seems that currently (flyway 7.7.2) does not recognize a URL that starts with "jdbc:as400:" as a Db2 URL, so it throws an exception, which is the reason that the jt400.jar style URL is rejected with exception:

    "No database found to handle ..."

    The github history tells a story (see: https://github.com/flyway/flyway/issues/105).

    Looks like the devs did not succeed to get the AS400 support added due to the lack of a suitable available i-series testing/dev environment (and also available to travis ci) . There may have been at least one PR for such support in the past, although it seems to be removed.

    If you try to use the IBM db2jcc4.jar driver to connect to i-series (as400) with a url similar to: jdbc:db2://hostname/dbname, and you explicitly use an IBM jre , and have the relevant license file (e.g. db2jcc_license_cisuz.jar on the CLASSPATH), then flyway will connect and then report the exception similar to:

    Unsupported Database: AS 7.4

    The flyway source code shows that flyway does not recognize this database product-name and version, at current flyway version 7.7.2.