Home > Software design >  SpringBoot H2 Database loosing data in the every execute
SpringBoot H2 Database loosing data in the every execute

Time:03-31

I connected to h2 database and i'm posting the entity while using postman. But I loose the data everytime when I rerun the my code.

      spring.h2.console.enabled=true
      spring.datasource.url = jdbc:h2:mem:crm/db_;DB_CLOSE_DELAY=-1
      spring.datasource.driver-class-name=org.h2.Driver
      spring.datasource.username=sa
      spring.datasource.password=
      spring.jpa.show-sql=true
      spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
      spring.jpa.hibernate.ddl-auto=update

Is there anyway to storage data in H2Database?

CodePudding user response:

Your datasource url specifies it as an in-memory database (h2:mem). You can specify it to store data in a file (in embedded mode) - see http://www.h2database.com/html/cheatSheet.html.

  • Related