11

I'm working with a Spring boot Application connecting to an AS400 Database using the com.ibm.db2.jcc.DB2Driver driver with Spring Data JPA. I use the org.hibernate.dialect.DB2Dialect dialect. When I start the Application, I get the Error

Could not fetch the SequenceInformation from the database
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=SYSCAT.SEQUENCES;TABLE, DRIVER=4.26.14

Meaning the Table SYSCAT.SEQUENCES is missing, which it is, because it's not needed. The Application works fine, but the error bothers me. As far as I see, SequenceInformations are only important when I generate an ID somewhere, what I don't do. This Application is only used to copy data from one place to another, so I only use JPAs @Id annotation but not the @GeneratedValue one. Am I missing some use for the SequenceInformation? Is there some way to turn off the fetching of SequenceInformation?

Those are my application properties:

spring:
  datasource:
    driver-class-name: com.ibm.db2.jcc.DB2Driver
    hikari.connection-test-query: values 1
    hikari.maximum-pool-size: 25
  jpa:
    database-platform: DB2Platform
    hibernate.ddl-auto: none
    open-in-view: false
    properties:
      hibernate:
        dll-auto: none
        dialect: org.hibernate.dialect.DB2Dialect
        naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
mustaccio
  • 18,234
  • 16
  • 48
  • 57
Urr4
  • 611
  • 9
  • 26
  • Hi, thanks for this question, i had the same problem and same scenario, i sugges to change the title of question to "sequence information cannot be fetched frim DB2" and thanks again – Med Aziz CHETOUI Jul 28 '22 at 09:39

2 Answers2

24

You use the wrong dialect. Please use:

org.hibernate.dialect.DB2400Dialect
Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
  • Could you please point to any documentation for this. Not sure why every post and documentation suggests using org.hibernate.dialect.DB2Dialect – bluelurker Sep 07 '20 at 20:51
  • 1
    Man!! I have been searching for this since last 4 hours. Thank you for this answer. – Divyesh Kalbhor Jan 06 '21 at 10:23
  • Thanks, i had the same problem and i found this response is very useful – Med Aziz CHETOUI Jul 28 '22 at 09:40
  • yes but now there is a warning "DB2AS400Diealect is deprecated, use DB2Dialect instead" but using DB2Dialect there is an error "SEQUENCES in SYSCAT of type *FILE not found"... – abrfra Aug 16 '23 at 08:02
3

I have changed dialect from DB2Dialect to DB2400Dialect and it worked for me.

##spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.DB2Dialect
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.DB2400Dialect
Hanamant Jadhav
  • 627
  • 7
  • 12