I have successfully created a spring boot application that uses the H2 embedded database in-memory. I would now like to change this to a file based version that will persist
Using the following setting on application.properties, I manage to keep the data persisted even after shutting down and restarting SpringBoot, and even after restarting the computer.
spring.datasource.name=japodb
spring.datasource.initialize=false
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:file:~/japodb;DB_CLOSE_ON_EXIT=FALSE;IFEXISTS=TRUE;DB_CLOSE_DELAY=-1;
Don't Close a Database when the VM Exits, yes, but also don’t make a new database if it’s already there.
jdbc:h2:;IFEXISTS=TRUE
spring.jpa.hibernate.ddl-auto = update