'How to fix h2-databse not found
This is my first spring boot application. I am trying to connect the database using h2-console. But when I trying to do it I am getting an error. The error is,
Database "/Users/MyName/test" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help)
I have shown h2-conosle image above. I did not use any code in application.property file. As well as I have used below mentioned dependency also.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
First My port was 8080 Then also this not worked. After that, the port has been changed to 8082. even it not working.
Solution 1:[1]
The easy way to fix the problem may be to change the JDBC URL to jdbc:h2:mem:testdb
Another way to fix the issue is to add a version number with the maven dependency (from https://mvnrepository.com/artifact/com.h2database/h2). If you could add the dependency like below and rerun the application, the URL will be corrected.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>test</scope>
</dependency>
Solution 2:[2]
One more easy way to create the database in Windows is when you run the C:\Program Files (x86)\H2\bin h2w.bat, you get a option as shown in the screen shots. You can create the database using the option Create a new database. And then use the same connection details to connect to the newly created h2 database.
Solution 3:[3]
First approach
- Search for h2 in spring boot logs, there will be log like H2 console available at '/console'. Database available at 'jdbc :h2:mem:5bcffde7-27bd-4d59-9ad1-3bc12635f0bf'. Note: /console is the path, i chosen for h2-console in application.properties, this will vary according to the path you have chosen.
- Copy the url without single quotes and no spaces between them i.e jdbc:h2:mem:5bcffde7-27bd-4d59-9ad1-3bc12635f0bf.
- Enter this in the JDBC Url in h2-console.
- Then you should be able to connect to it.
The second and simpler approach
Configuring the h2 database url in application.properties without the need of spring randomly generating it.
spring.datasource.url=jdbc:h2:mem:testdb
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Ajaya Krishna |
| Solution 3 |



