Problems to generate model for MSSQL tables that have primary key

I am trying to generate model for a MSSQL 2005 database that uses tableName_oid as pattern for primary keys.

When i select tables that have primary key constraints and i click ‘next’, Studio throws a message that “The column name IS_AUTOINCREMENT is not valid.” It only happens with tables that have primary key constraints (works if i drop the PK constraint).

Example of table that works fine:


CREATE TABLE
    Estado
    (
        estado_oid UNIQUEIDENTIFIER,
        codigo VARCHAR(2) COLLATE Latin1_General_CI_AS,
        codigoTE VARCHAR(20) COLLATE Latin1_General_CI_AS NOT NULL,
        nome VARCHAR(50) COLLATE Latin1_General_CI_AS,
        ultimaAtualizacao DATETIME,
        autorizado BIT
    );

Example of table that does not work:


CREATE TABLE
    TipoPassaporte
    (
        tipoPassaporte_oid UNIQUEIDENTIFIER NOT NULL,
        codigo CHAR(1) COLLATE Latin1_General_CI_AS,
        descricao VARCHAR(30) COLLATE Latin1_General_CI_AS,
        ultimaAtualizacao DATETIME,
        autorizado BIT,
        CONSTRAINT PKTipoPassaporte PRIMARY KEY (tipoPassaporte_oid),
        CONSTRAINT TipoPassaporteEK UNIQUE (codigo)
    );

Solved it by just changing the db url to jdbc:jtds, generating the model and coming back to default mssql url again.

Hi,
At the moment of writing, CUBA Platform and Studio use mssql-jdbc-6.1.0. This driver supports SQL Server since version 2008 (see the system requirements section).
JTDS supports SQL Server 2005, so you have found a valid approach.
Thank you.

We are also going to add support for jTDS in the release 6.7, see https://youtrack.cuba-platform.com/issue/PL-9467

1 Like

I have the same problem with a SQL SERVER 2005 database. How can I change the database URL to indicate the jtds driver?

Hi,
In Studio 6.7 you can select SQL Server 2005 and the correct context.xml will be generated.
image

<Resource driverClassName="net.sourceforge.jtds.jdbc.Driver"
              maxIdle="2"
              maxTotal="20"
              maxWaitMillis="5000"
              name="jdbc/CubaDS"
              password="saPass1"
              type="javax.sql.DataSource"
              url="jdbc:jtds:sqlserver://localhost/test"
              username="sa"
              validationQuery="select 1"/>