Issue
I cannot login to my H2 Database event though i see the message that the database is available.
DEBUG [main] [Log Context: ] org.springframework.jdbc.datasource.DriverManagerDataSource:134 Loaded JDBC driver: org.h2.Driver
DEBUG [main] [Log Context: ] org.springframework.jdbc.datasource.DriverManagerDataSource:144 Creating new JDBC DriverManager Connection to [jdbc:h2:mem:testdb]
INFO [main] [Log Context: ] o.s.boot.autoconfigure.h2.H2ConsoleAutoConfiguration:68 H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
My application.properties
file looks like this:
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
and the database not found error messsage looks like this:
I am using h2database version 2.1.214 and spring boot version 2.5.9
Solution
at first try to add next properties to the Data Base URL:
DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
Example:
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
Answered By - Jackkobec
Answer Checked By - David Marino (JavaFixing Volunteer)