1

I am writing a desktop applicaiton, which requires language dictationary.

I want my application to create h2 database only when user first time run my application, and then load translations into db from .xdxf dictationary.

After a quick looking through a few articles I got that the common use case is to create a new schema every time when application starts and destroy it on exit. Did I get it correctly?

Is there a way to keep created schema after application was stopped?

P.S. any link for suitable tutorial will be enougth for me. Thanks.

sinedsem
  • 5,413
  • 7
  • 29
  • 46

1 Answers1

1

You are referring to what Spring Boot does by default. You can configure it in many ways, reading the documentation should help.

H2 can also be configured in many ways, including file-based persistence (i.e. surviving a restart of the application).

With your current setup that works with H2 in memory, you could give this configuration a try and look at the doc for the remaining pieces:

spring.datasource.url = jdbc:h2:file:~/testdb

We will figure out the driver based on the URL. Note that since you took control over this setup, Hibernate won't be configured to create the schema automatically on startup (if you were relying on that). Check this question for more details.

Community
  • 1
  • 1
Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89