I Use a Spring Boot 2 with file based HSQLDB. This are my properties
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:file:${user.dir}/src/main/resources/userdb
spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=update
After application start I use that DB and add some Elements into it. Everything works, after that I expect under the path src/main/resources/ following files.
- userdb.log (exists)
- userdb.properties (exists)
- userdb.script (exists)
- userdb.data (where is this?)
But userdb.data is not there, after application restart all data are gone. Userdb.script contains all INSERT commands of data I added but there is no .data file. How to configure Spring Boot to create a userdb.data file and use this with content after restart.
In short, I want a persistent HSQLDB.
CodePudding user response:
The database you've already got is persistent and is fine for small (a few megabytes) data.
The .data file is created when you execute CREATE CACHED TABLE statements or when you specify the default table type to be CACHED.
spring.datasource.url=jdbc:hsqldb:file:${user.dir}/src/main/resources/userdb;hsqldb.default_table_type=cached
See the Guide: http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_db_operations