0

I've my spring-boot application working with H2 DB on the file.

The current H2 db string is:

spring.datasource.url: jdbc:h2:./myApp-@project.version@;DB_CLOSE_ON_EXIT=TRUE

When I save my objects into the DB using the dao:

@Transactional public interface MyDao extends JpaRepository { }

myDao.save(new MyEntity(var1, var2);

and I stop my application with

SpringApplication.exit(applicationContext, exitCode);

everything is ok, at the next restart the DB contains the saved objects.

The problem is when I start the application, I save something in the DB and the java process is killed. At the next restart the saved datas are lost.

Can someone help me?

Thank you in advance!

uschti
  • 21
  • 5
  • Can you give more details about "I save something in the DB and the java process is killed" ? – davidxxx Dec 10 '16 at 19:40
  • I use my Dao to save the entity: @Transactional public interface MyDao extends JpaRepository { } myDao.save(new MyEntity(var1, var2)); – uschti Dec 10 '16 at 19:54
  • And who kill the java process ? You ? Can you post the log if it contains some information ? – davidxxx Dec 10 '16 at 19:55
  • I kill the java process (kill -9 processId), for test purpose OR the system shutdown unexpectedly. The log contains no informations after the kill – uschti Dec 10 '16 at 20:01
  • In this case, it has no relation with Spring Boot. You want to check the solidity of the recovery. In this case, you should use tools provided by H2 to check if the recovery works. Look at "Using the Recover Tool" in http://www.h2database.com/html/advanced.html – davidxxx Dec 10 '16 at 20:09
  • http://stackoverflow.com/questions/36913643/hsql-db-lost-when-spring-boot-app-restarts try this sol. not sure about u but it helped me – Waheeda Feb 09 '17 at 12:59

0 Answers0