1

My application has 3 components,

1) A user facing component that receives requests and stores into the DB 2) A backend component that reads data form the DB, processes it and sends it on to an external system. 3) A DB that stores user input

enter image description here I am currently testing using H2 in memory database (NOT file based) from eclipse. I want to test end to end, but the problem is I have stop the user facing component and start the backend component. So, the DB gets created from scratch each time I start the backend component.

How do I test so that the flow is like this: user enters data -> data persisted into DB -> Baackend connects to the same persisted data -> processes data + passes to external system?

NOTE: I tried using ddl-auto: update, but it doesn't work.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
Deepboy
  • 523
  • 3
  • 16
  • 28

2 Answers2

5

In addition to spring.jpa.hibernate.ddl-auto=update, set auto_reconnect as true.

Example:

spring.datasource.url=jdbc:h2:file:~/test2;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE
spring.datasource.driver-class-name=org.h2.Driver
Sundararaj Govindasamy
  • 8,180
  • 5
  • 44
  • 77
0

This database supports multiple connection modes and connection settings. This is achieved using different database URLs. Please see the link below for official documentation.

Reference: https://www.h2database.com/html/features.html#database_url