Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 with MODE=Oracle causes 'Schema "information_schema" not found'

I'm building app with Spring Boot 1.5.4.RELEASE and I want to use H2 with Flyway.

My application.properties are:

spring.datasource.url=jdbc:h2:mem:test;MODE=Oracle;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;AUTO_RECONNECT=TRUE;INIT=create schema if not exists test;
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
spring.jpa.generate-ddl=false
spring.jpa.hibernate.ddl-auto=validate

flyway.baseline-version=0.0.1
flyway.sql-migration-prefix=Migration-
flyway.table=SCHEMA_HISTORY
flyway.locations=filesystem:src/schema/bundle

Error I'm getting is:

Caused by: org.h2.jdbc.JdbcSQLException: Schema "information_schema" not found; SQL statement:
select SEQUENCE_CATALOG, SEQUENCE_SCHEMA, SEQUENCE_NAME, INCREMENT from information_schema.sequences [90079-195]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.message.DbException.get(DbException.java:179) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.message.DbException.get(DbException.java:155) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.getSchema(Parser.java:682) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.getSchema(Parser.java:688) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.readTableFilter(Parser.java:1218) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1940) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parseSelectSimple(Parser.java:2089) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parseSelectSub(Parser.java:1934) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parseSelectUnion(Parser.java:1749) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parseSelect(Parser.java:1737) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parsePrepared(Parser.java:448) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parse(Parser.java:320) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.parse(Parser.java:292) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.command.Parser.prepareCommand(Parser.java:257) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.engine.Session.prepareLocal(Session.java:573) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.engine.Session.prepareCommand(Session.java:514) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204) ~[h2-1.4.195.jar:1.4.195]
    at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:74) ~[h2-1.4.195.jar:1.4.195]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) ~[tomcat-jdbc-8.5.15.jar:na]

Setting spring.jpa.hibernate.ddl-auto to none solves the issue, but I want to keep my schema validated against the model (already encountered one nasty bug). I guess that it's the right way. What am I missing?

like image 922
otocon Avatar asked Jul 20 '17 16:07

otocon


1 Answers

Setting CASE_INSENSITIVE_IDENTIFIERS = true fixed this same problem for me. I was using version 1.4.194 of com.h2database and this didn't seem to work, but updating it to 1.4.200 did.

I did, however, also remove the INIT=create schema if not exists parameter, letting Spring create the tables via the spring.jpa.hibernate.ddl-auto setting, so not sure if this was also a factor.

like image 147
pancakesmaplesyrup Avatar answered Oct 16 '22 22:10

pancakesmaplesyrup