Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 database - how to init multiple schema (yml)

Tags:

java

yaml

jdbc

h2

My conf (working):

    jdbc-url: jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS MYSCHEMA_1

I need to init mulitple schema, but i can't find the syntax. So far I tried:

jdbc-url: jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS MYSCHEMA_1, MYSCHEMA_2
jdbc-url: jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS MYSCHEMA_1;CREATE SCHEMA IF NOT EXISTS MYSCHEMA_2
jdbc-url: jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS MYSCHEMA_1;INIT=CREATE SCHEMA IF NOT EXISTS MYSCHEMA_2
like image 373
Tyvain Avatar asked Dec 11 '22 04:12

Tyvain


1 Answers

Solution is:

jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS SCHEMA_1\;CREATE SCHEMA IF NOT EXISTS SCHEMA_2

note the simple '\' in yml. Double '\\' in java is to escape the first one.

like image 136
Tyvain Avatar answered Feb 11 '23 03:02

Tyvain