Search code examples
javaspringspring-mvcspring-boothsqldb

Spring boot: configure hsqldb datasource to persist data


I am trying to create a spring boot app. I want to persist data using hsql database.

first I did include hsqldb maven dependency and springboot auto-configure is working fine, but after app restart data is lost.

Then I did include following configuration in application.peoprties file

spring.datasource.url = jdbc:hsqldb:file:testdb.script
spring.datasource.username = SA
spring.datasource.password = 

#JPA properties
spring.jpa.generate-ddl=true

But data is still not persisted. What should be configuration for persisting data? Thanks for helping.


Solution

  • The default for spring.jpa.hibernate.ddl-auto is create-drop if you use an embedded database. Update this in your properties to spring.jpa.hibernate.ddl-auto=validate or none