Manuel Dierkes
Manuel Dierkes

Reputation: 53

Why do I get a column unknown exception in Firebird with jooq?

I want to generate some classes with Jooq.

Jooq Version: 3.8.2 Firebird Version: 2.5 JDBC-Firebird-Driver: 2.1.6

Here is my Config.xml:

   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.7.0.xsd">
    <jdbc>
        <driver>org.firebirdsql.jdbc.FBDriver</driver>
        <url>jdbc:firebirdsql:localhost/3050://var/lib/firebird/2.5/data/db.gdb?encoding=ISO8859_1</url>
        <user>sysdba</user>
        <password>masterkey</password>
    </jdbc>
    <generator>
        <name>org.jooq.util.JavaGenerator</name>
        <database>
            <name>org.jooq.util.firebird.FirebirdDatabase</name>
            <includes>.*</includes>
            <excludes>RDB\$.*|MON\$.*|SEC\$.*</excludes>
            <inputSchema></inputSchema>
        </database>
        <generate>
            <pojosEqualsAndHashCode>true</pojosEqualsAndHashCode>
            <pojos>true</pojos>
        </generate>
        <target>
            <packageName>models.gen</packageName>
            <directory>./app</directory>
        </target>
    </generator>
</configuration>

If I run jooq, I get a SQL error:

    SQL error code = -206
Column unknown
RDB$PROCEDURES.RDB$PROCEDURE_TYPE
At line 1, column 208

Please report this bug here: https://github.com/jOOQ/jOOQ/issues/new


  select 
    trim("RDB$RELATIONS"."RDB$RELATION_NAME"), 
    0 "table_valued_function"
  from "RDB$RELATIONS"
union all 
  select 
    trim("RDB$PROCEDURES"."RDB$PROCEDURE_NAME"), 
    1 "table_valued_function"
  from "RDB$PROCEDURES"
  where (
    "RDB$PROCEDURES"."RDB$PROCEDURE_TYPE" = 1
    and 1 = 0
  )
order by 1 asc
Jun 27, 2016 11:35:01 AM org.jooq.tools.JooqLogger error
SCHWERWIEGEND: Error while fetching tables
org.jooq.exception.DataAccessException: SQL [select trim("RDB$RELATIONS"."RDB$RELATION_NAME"), 0 "table_valued_function" from "RDB$RELATIONS" union all select trim("RDB$PROCEDURES"."RDB$PROCEDURE_NAME"), 1 "table_valued_function" from "RDB$PROCEDURES" where ("RDB$PROCEDURES"."RDB$PROCEDURE_TYPE" = cast(? as smallint) and 1 = 0) order by 1 asc]; GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -206
Column unknown
RDB$PROCEDURES.RDB$PROCEDURE_TYPE
At line 1, column 208
        at org.jooq.impl.Tools.translate(Tools.java:1908)
        at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:659)
        at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:362)
        at org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:312)
        at org.jooq.impl.AbstractResultQuery.iterator(AbstractResultQuery.java:323)
        at org.jooq.impl.SelectImpl.iterator(SelectImpl.java:2715)
        at org.jooq.util.firebird.FirebirdDatabase.getTables0(FirebirdDatabase.java:241)
        at org.jooq.util.AbstractDatabase.getTables(AbstractDatabase.java:980)
        at org.jooq.util.SchemaDefinition.getTables(SchemaDefinition.java:74)
        at org.jooq.util.JavaGenerator.generateSchema(JavaGenerator.java:3638)
        at org.jooq.util.JavaGenerator.generateSchema(JavaGenerator.java:3604)
        at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:350)
        at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:317)
        at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:282)
        at org.jooq.util.GenerationTool.run(GenerationTool.java:533)
        at org.jooq.util.GenerationTool.generate(GenerationTool.java:195)
        at org.jooq.util.GenerationTool.main(GenerationTool.java:166)
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -206
Column unknown
RDB$PROCEDURES.RDB$PROCEDURE_TYPE
At line 1, column 208
        at org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:147)
        at org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:46)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:92)
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:890)
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:845)
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:838)
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:314)
        at org.jooq.impl.ProviderEnabledConnection.prepareStatement(ProviderEnabledConnection.java:112)
        at org.jooq.impl.SettingsEnabledConnection.prepareStatement(SettingsEnabledConnection.java:76)
        at org.jooq.impl.AbstractResultQuery.prepare(AbstractResultQuery.java:231)
        at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:320)
        ... 14 more

The column RDB$PROCEDURE_TYPE is really not exists in my Firebird DB.

How can I fix this?

Upvotes: 3

Views: 1662

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 109239

The column RDB$PROCEDURE_TYPE was introduced in Firebird 2.0 (On-Disk-Structure (ODS) 11.0). By the looks of it your database is ODS 10 (Interbase 6/Firebird 1.0). To get this column in your database, you need to upgrade the ODS by backing up your database and restoring it. This will upgrade your database to ODS 11.2 (Firebird 2.5).

Upvotes: 2

Related Questions