Home > Software engineering >  h2 url format error when setting newly created schema
h2 url format error when setting newly created schema

Time:09-28

I have an error when using url for in memory h2 database. Following format for url property is used:

spring:
  datasource:
    username: sa
    url: jdbc:h2:mem:master;MODE=MSSQLServer;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=FALSE;DB_CLOSE_ON_EXIT=false;CASE_INSENSITIVE_IDENTIFIERS=TRUE;TRACE_LEVEL_SYSTEM_OUT=2;INIT=CREATE SCHEMA IF NOT EXISTS dbo\\;SET SCHEMA dbo;

but for some reason the error indicates that the format is not correct:

org.h2.jdbc.JdbcSQLNonTransientConnectionException: URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:master" [90046-200]

I also tried replacing \\;SET SCHEMA dbo; with SCHEMA=dbo but it does not seem to find the dbo schema in this case.

Any suggestions are appreciated. Thanks!

CodePudding user response:

You need to replace \\; with \; before SET SCHEMA.

  • Related