Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with INIT=RUNSCRIPT and relative paths

I use maven conventions for source paths (src/main src/test) and i have my sql scripts in src/main/resources/scripts.

I want to run my app with H2 memory and i'd like to use the jdbc url to initialize my db :

database.url=jdbc:h2:mem:;INIT=RUNSCRIPT FROM 'src/main/resources/scripts/create.sql'; 

My problem is that this relative path (src/main/... ) does not work, and that H2 won't crash if the init=runscript command targets nothing.

Does someone know what is the path i should use to make this work ?

Thanks

like image 213
Maxime ARNSTAMM Avatar asked Dec 20 '10 13:12

Maxime ARNSTAMM


1 Answers

You can use the following url:
"jdbc:h2:mem:sample;INIT=RUNSCRIPT FROM 'classpath:scripts/create.sql'"

With that one it is possible to run script from classpath. So you can just put it src/main/resources/scripts or src/test/resources/scripts in your maven (or something else) project.

like image 87
viktortnk Avatar answered Sep 19 '22 18:09

viktortnk