springboot 2.3.0 while connecting to h2 database
You can fix this by setting the spring.datasource.url
property like so:
spring.datasource.url=jdbc:h2:mem:testdb
Prior to Spring Boot 2.3.0-RELEASE this was the default, but I'm not sure where it's set. As of 2.3.0-RELEASE, the schema looks to be a randomly generated GUID.
Step 1. In application.properties:
spring.h2.console.enabled=truespring.datasource.url=jdbc:h2:mem:testdb
Step 2. Start your Spring Boot App and open:
http://localhost:8080/h2-console/
If you still face issue try pasting the URL value which you mentioned in application.properties jdbc:h2:mem:testdb
in
JDBC URL of h2-console
Then you wont face below mentioned issueDatabase h2 not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help)
Actually, your h2 databse is looking for a file called test.mv.db. Butthat file was not present in your user directory. So, that it justslapping you and asking you to pre-create it in that path.
Note: That is the root file where our H2 DB store all our information.
Add below line in your
application.properties
filespring.datasource.url = jdbc:h2:mem:testdb
Go to your user directory, in my case, it is (C:\Users\subra)
Create a new file called
test.mv.db
and saved it under all file option like below.Now restart your app.
Done
Reference Screenshot: