Sagar Bahadur Tamang
Sagar Bahadur Tamang

Reputation: 2709

Unable to create embedded h2 database

I am using the web console of H2 Version 1.4.198 (2019-02-22) to create a embedded database. But I am getting the following error saying "unable to find the database". I want to create the database not open an existing one. I using ubuntu 18.04 and have given execute permisison to h2.jar and h2.sh.

Error

Upvotes: 0

Views: 2322

Answers (2)

Raghuram
Raghuram

Reputation: 52665

I get the same error with the latest (1.4.198) version. It works for me with the stable version - 1.4.197. @sagar-bahadur-tamang can you check your version and try suitably?

Upvotes: 1

Mayur
Mayur

Reputation: 904

In application.properties or yaml file check spring.datasource.url remove the flag IFEXISTS=TRUE;.

If the flag is set to true, the connection is only established if the database exists. For reference of the flag see http://www.h2database.com/html/features.html#database_only_if_exists

The application properties file should look like as below

application.properties

h2.datasource.driver-class-name=org.h2.Driver
h2.datasource.url=jdbc:h2:file:~/test;DB_CLOSE_ON_EXIT=TRUE;FILE_LOCK=NO
h2.datasource.username=sa
h2.datasource.password=

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console/

It looks like as below (Test Connection is successful)

enter image description here

Upvotes: 1

Related Questions