Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

springboot 2.3.0 while connecting to h2 database

In Springboot 2.3.0.RELEASE I am getting the the following error while connecting to h2 database in the console

Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149

like image 658
ramesh b Avatar asked May 18 '20 08:05

ramesh b


People also ask

Which property is correct to enable the H2 Database in spring boot application?

H2 Console Before accessing the H2 database, we must enable it by using the following property. Once we have enabled the H2 console, now we can access the H2 console in the browser by invoking the URL http://localhost:8080/h2-console. The following figure shows the console view of the H2 database.

Can we use JPA with H2 database?

In this article, you'll learn how to use Spring Data JPA with the H2 database in a Spring Boot project for storing, accessing, updating and deleting data (CRUD operations). H2 is an open-source in-memory SQL database written in Java.

How do I open my H2 console?

Access the H2 Console You can access the console at the following URL: http://localhost:8080/h2-console/. You need to enter the JDBC URL, and credentials.


Video Answer


2 Answers

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.

like image 67
chacewells Avatar answered Sep 17 '22 07:09

chacewells


Step 1. In application.properties:

spring.h2.console.enabled=true spring.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 issue Database h2 not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help)

like image 44
Yoshita Mahajan Avatar answered Sep 18 '22 07:09

Yoshita Mahajan