I'm trying to use the H2 database in a Spring Boot project. When I run a project, a database error pops up:
Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE"; to the db URL) [90121-199]
When I add: ";DB_CLOSE_ON_EXIT=FALSE"; this url also closes but without warning. What could be the problem?
application.properties:
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.datasource.url=jdbc:h2:file:~/database
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
Maven pom:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
If you still need it, for me the that problem was resolved adding the reference to module web of Spring in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
add the below line in application.property file
spring.jpa.defer-datasource-initialization=true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With