How to add new database type JTOpen (ibm as400)

How to setup a new DatabaseType in CUBA to support JTOpen for connection to the AS/400 database (JT400)

Hi,
First of all, you should check that this database is supported by EclipseLink which is an ORM implementation used by CUBA.

Then refer to the documentation:
https://doc.cuba-platform.com/manual-7.0/arbitrary_dbms.html

https://doc.cuba-platform.com/studio/?_ga=2.222198109.477038308.1563779859-237267920.1554359693#custom_db

Thank you Alex,

The last link was very useful to start.

5.2.5. Integrating with Custom Database ](CUBA Studio User Guide)

Select CUBA > Advanced > Define Custom Database in the menu.

Is it possible to override the create table SYS_DB_CHANGELOG ?
AS/400 does not support the default value on the field CRATE_TS, see the error message:

> Task :app-core:createDb

[CubaDbCreation]
Using database URL: jdbc:as400://xxx.xxx.xxx/cuba, user: CUBA
Failed to execute: create table SYS_DB_CHANGELOG (
SCRIPT_NAME varchar(300) not null primary key,
CREATE_TS DATE default current_timestamp,
IS_INIT integer default 0) because: [SQL0574] Column or sequence attribute is not valid.

Hi @mile.simic. Of course available. In build.gradle script file for task createDb override CubaDbCreation type on your.
Example:

task createDb(dependsOn: assembleDbScripts, description: ‘Creates local database’, type: MyCubaDbCreation) { …

Add implementation class to the end of the file.

class MyCubaDbCreation extends CubaDbCreation {
@Override
protected void createSysDbChangeLogTable() {
    try {
        getSql().executeUpdate(String.format("create table SYS_DB_CHANGELOG (\n" +
                "SCRIPT_NAME varchar(%s) not null primary key, \n" +
                "CREATE_TS %s, \n" +
                "IS_INIT integer default 0)", 300, timeStampType))
    } catch (SQLException e) {
        throw new RuntimeException("Exception during DB creation", e)
    }
}

Hi,
It seems that you have integrated CUBA with jt400 driver (AS400). Do you have a sample project to share? I am trying to configure custom DB but I am going crazy with JDBC error…

Dear Samu, see the link for a small demo project.
https://www.ez-software.eu/downloads/cuba/DemoAS400DB2.zip

Note, CUBA does not support AS/400 as main database.

@samu.sadocco
Do you need help with the demo project?

|### Samuele Sadocco|18:50 (0 minuti fa)||

a Mile

|

Dear Mile,

finally I was able to connect the application to our AS400 (changing the connection parameters of the additional datastore).

Thank you a lot for your help!!

Sam