Import schema.sql into a specificic H2 database with Spring Boot

Viewed 830

I'm struggling to understand if I can import the data defined inside my schema.sql and data.sql into a specific H2 database.

I use Spring Boot 2.0.6 and this is the configuration inside my application.properties:

# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2

# Datasource
spring.datasource.url=jdbc:h2:mem:assignment
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver

And I correctly placed both schema.sql and data.sql inside the resources folder.

resources

The application starts up correctly and imports the files:

2018-10-26 20:39:24.834  INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/schema.sql]
2018-10-26 20:39:24.848  INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/schema.sql] in 13 ms.
2018-10-26 20:39:24.850  INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/data.sql]
2018-10-26 20:39:24.868  INFO 9448 --- [main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/C:/Users/Gabriele/code/java/assignment/target/classes/data.sql] in 18 ms.

But when I open the browser console, the assignment database is empty

assigment database

while the test one is not.

test

What am I missing?

0 Answers
Related