Cannot Connect to my H2 Database

i am trying to connect to metabase using the default h2 database , i had no issues with it previously but now when i try to run it using the command java -jar metabase.jar i run through this error

C:\Users\DMS-ADMIN\Desktop\AI_HMIS\AI_HMIS\Metabase>java -jar metabase.jar
2024-02-11 20:55:24,312 INFO metabase.util :: Maximum memory available to JVM: 6.0 GB
2024-02-11 20:55:26,046 WARN db.env :: WARNING: Using Metabase with an H2 application database is not recommended for production deployments. For production deployments, we highly recommend using Postgres, MySQL, or MariaDB instead. If you decide to continue to use H2, please be sure to back up the database file regularly. For more information, see https://metabase.com/docs/latest/operations-guide/migrating-from-h2.html
2024-02-11 20:55:26,202 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance.
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
2024-02-11 20:55:35,171 INFO driver.impl :: Registered abstract driver :sql
2024-02-11 20:55:35,187 INFO driver.impl :: Registered abstract driver :sql-jdbc (parents: [:sql])
2024-02-11 20:55:35,187 INFO metabase.util :: Load driver :sql-jdbc took 94.6 ms
2024-02-11 20:55:35,187 INFO driver.impl :: Registered driver :h2 (parents: [:sql-jdbc])
2024-02-11 20:55:35,390 INFO driver.impl :: Registered driver :mysql (parents: [:sql-jdbc])
2024-02-11 20:55:35,437 INFO driver.impl :: Registered driver :postgres (parents: [:sql-jdbc])
2024-02-11 20:55:37,374 INFO metabase.core ::
Metabase v0.48.1 (a8302d4)

Copyright ⌐ 2024 Metabase, Inc.

Metabase Enterprise Edition extensions are NOT PRESENT.
2024-02-11 20:55:37,390 INFO metabase.core :: Starting Metabase in STANDALONE mode
2024-02-11 20:55:37,437 INFO metabase.server :: Launching Embedded Jetty Webserver with config:
 {:port 3000}

2024-02-11 20:55:37,499 INFO metabase.core :: Starting Metabase version v0.48.1 (a8302d4) ...
2024-02-11 20:55:37,499 INFO metabase.core :: System info:
 {"file.encoding" "Cp1252",
 "java.runtime.name" "Java(TM) SE Runtime Environment",
 "java.runtime.version" "11.0.20+9-LTS-256",
 "java.vendor" "Oracle Corporation",
 "java.vendor.url" "https://openjdk.java.net/",
 "java.version" "11.0.20",
 "java.vm.name" "Java HotSpot(TM) 64-Bit Server VM",
 "java.vm.version" "11.0.20+9-LTS-256",
 "os.name" "Windows Server 2019",
 "os.version" "10.0",
 "user.language" "en",
 "user.timezone" "Africa/Cairo"}

2024-02-11 20:55:37,515 INFO metabase.plugins :: Loading plugins in C:\Users\DMS-ADMIN\Desktop\AI_HMIS\AI_HMIS\Metabase\plugins...
2024-02-11 20:55:37,999 INFO plugins.classloader :: Added URL file:/C:/Users/DMS-ADMIN/Desktop/AI_HMIS/AI_HMIS/Metabase/plugins/ojdbc8.jar to classpath
2024-02-11 20:55:37,999 INFO plugins.classloader :: Added URL file:/C:/Users/DMS-ADMIN/Desktop/AI_HMIS/AI_HMIS/Metabase/plugins/orai18n.jar to classpath
2024-02-11 20:55:38,046 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :athena...
2024-02-11 20:55:38,062 INFO driver.impl :: Registered driver :athena (parents: [:sql-jdbc])
2024-02-11 20:55:38,077 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :bigquery-cloud-sdk...
2024-02-11 20:55:38,077 INFO driver.impl :: Registered driver :bigquery-cloud-sdk (parents: [:sql])
2024-02-11 20:55:38,077 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :druid...
2024-02-11 20:55:38,077 INFO driver.impl :: Registered driver :druid
2024-02-11 20:55:38,093 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :googleanalytics...
2024-02-11 20:55:38,093 INFO driver.impl :: Registered driver :googleanalytics
2024-02-11 20:55:38,093 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :mongo...
2024-02-11 20:55:38,093 INFO driver.impl :: Registered driver :mongo
2024-02-11 20:55:38,124 INFO plugins.dependencies :: Metabase Oracle Driver dependency {:class oracle.jdbc.OracleDriver} satisfied? true
2024-02-11 20:55:38,124 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :oracle...
2024-02-11 20:55:38,124 INFO driver.impl :: Registered driver :oracle (parents: [:sql-jdbc])
2024-02-11 20:55:38,140 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :presto-jdbc...
2024-02-11 20:55:38,140 INFO driver.impl :: Registered driver :presto-jdbc (parents: [:sql-jdbc])
2024-02-11 20:55:38,140 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :redshift...
2024-02-11 20:55:38,140 INFO driver.impl :: Registered driver :redshift (parents: [:postgres])
2024-02-11 20:55:38,171 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :snowflake...
2024-02-11 20:55:38,171 INFO driver.impl :: Registered driver :snowflake (parents: [:sql-jdbc])
2024-02-11 20:55:38,187 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :hive-like...
2024-02-11 20:55:38,187 INFO driver.impl :: Registered abstract driver :hive-like (parents: [:sql-jdbc])
2024-02-11 20:55:38,187 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :sparksql...
2024-02-11 20:55:38,187 INFO driver.impl :: Registered driver :sparksql (parents: [:hive-like])
2024-02-11 20:55:38,187 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :sqlite...
2024-02-11 20:55:38,187 INFO driver.impl :: Registered driver :sqlite (parents: [:sql-jdbc])
2024-02-11 20:55:38,202 DEBUG plugins.lazy-loaded-driver :: Registering lazy loading driver :sqlserver...
2024-02-11 20:55:38,202 INFO driver.impl :: Registered driver :sqlserver (parents: [:sql-jdbc])
2024-02-11 20:55:38,202 INFO plugins.dependencies :: Metabase cannot initialize plugin Metabase Vertica Driver due to required dependencies. Metabase requires the Vertica JDBC driver in order to connect to Vertica databases, but we can't ship it as part of Metabase due to licensing restrictions. See https://metabase.com/docs/latest/administration-guide/databases/vertica.html for more details.

2024-02-11 20:55:38,202 INFO plugins.dependencies :: Metabase Vertica Driver dependency {:class com.vertica.jdbc.Driver} satisfied? false
2024-02-11 20:55:38,202 INFO plugins.dependencies :: Plugins with unsatisfied deps: ["Metabase Vertica Driver"]
2024-02-11 20:55:38,202 INFO metabase.core :: Setting up and migrating Metabase DB. Please sit tight, this may take a minute...
2024-02-11 20:55:38,202 INFO db.setup :: Verifying h2 Database Connection ...
2024-02-11 20:56:08,780 ERROR metabase.core :: Metabase Initialization FAILED
clojure.lang.ExceptionInfo: Unable to connect to Metabase h2 DB. {}
        at metabase.db.setup$fn__50305$_AMPERSAND_f__50306$fn__50307.invoke(setup.clj:113)
        at metabase.db.setup$fn__50305$_AMPERSAND_f__50306.invoke(setup.clj:111)
        at metabase.db.setup$fn__50305$fn__50314.invoke(setup.clj:103)
        at metabase.db.setup$fn__50327$_AMPERSAND_f__50328$fn__50331$fn__50332.invoke(setup.clj:142)
        at metabase.util.jvm$do_with_us_locale.invokeStatic(jvm.clj:239)
        at metabase.util.jvm$do_with_us_locale.invoke(jvm.clj:225)
        at metabase.db.setup$fn__50327$_AMPERSAND_f__50328$fn__50331.invoke(setup.clj:139)
        at metabase.db.setup$fn__50327$_AMPERSAND_f__50328.invoke(setup.clj:138)
        at metabase.db.setup$fn__50327$fn__50339.invoke(setup.clj:132)
        at metabase.db$setup_db_BANG_$fn__50348.invoke(db.clj:69)
        at metabase.db$setup_db_BANG_.invokeStatic(db.clj:64)
        at metabase.db$setup_db_BANG_.invoke(db.clj:55)
        at metabase.core$init_BANG__STAR_.invokeStatic(core.clj:111)
        at metabase.core$init_BANG__STAR_.invoke(core.clj:97)
        at metabase.core$init_BANG_.invokeStatic(core.clj:154)
        at metabase.core$init_BANG_.invoke(core.clj:149)
        at metabase.core$start_normally.invokeStatic(core.clj:166)
        at metabase.core$start_normally.invoke(core.clj:160)
        at metabase.core$entrypoint.invokeStatic(core.clj:199)
        at metabase.core$entrypoint.doInvoke(core.clj:193)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$apply.invoke(core.clj:662)
        at metabase.bootstrap$_main.invokeStatic(bootstrap.clj:31)
        at metabase.bootstrap$_main.doInvoke(bootstrap.clj:28)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at metabase.bootstrap.main(Unknown Source)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
        at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692)
        at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
        at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:372)
        at clojure.java.jdbc$get_connection.invoke(jdbc.clj:274)
        at clojure.java.jdbc$db_query_with_resultset_STAR_.invokeStatic(jdbc.clj:1111)
        at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1093)
        at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1182)
        at clojure.java.jdbc$query.invoke(jdbc.clj:1144)
        at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1160)
        at clojure.java.jdbc$query.invoke(jdbc.clj:1144)
        at metabase.driver.sql_jdbc.connection$can_connect_with_spec_QMARK_.invokeStatic(connection.clj:333)
        at metabase.driver.sql_jdbc.connection$can_connect_with_spec_QMARK_.invoke(connection.clj:330)
        at metabase.db.setup$fn__50305$_AMPERSAND_f__50306$fn__50307.invoke(setup.clj:111)
        ... 31 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
        at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1507)
        at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)
        at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)
        ... 43 more
Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
        at java.base/java.io.FileInputStream.readBytes(Native Method)
        at java.base/java.io.FileInputStream.read(FileInputStream.java:279)
        at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:252)
        at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:292)
        at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:351)
        at java.base/java.io.FilterInputStream.read(FilterInputStream.java:107)
        at metabase.db.update_h2$head.invokeStatic(update_h2.clj:24)
        at metabase.db.update_h2$head.invoke(update_h2.clj:18)
        at metabase.db.update_h2$db_version.invokeStatic(update_h2.clj:45)
        at metabase.db.update_h2$db_version.invoke(update_h2.clj:38)
        at metabase.db.update_h2$update_if_needed_BANG_.invokeStatic(update_h2.clj:95)
        at metabase.db.update_h2$update_if_needed_BANG_.invoke(update_h2.clj:90)
        at metabase.db.data_source.DataSource.getConnection(data_source.clj:29)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:213)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
        at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
2024-02-11 20:56:08,796 INFO metabase.core :: Metabase Shutting Down ...
2024-02-11 20:56:08,796 INFO metabase.server :: Shutting Down Embedded Jetty Webserver
2024-02-11 20:56:08,796 INFO metabase.core :: Metabase Shutdown COMPLETE

is there a solution to this?

I got the same error, and version details below:
2024-02-24 11:20:17,372 INFO metabase.core :: Starting Metabase version v0.48.6 (b8818f9) ...
2024-02-24 11:20:17,380 INFO metabase.core :: System info:
{"file.encoding" "Cp1252",
"java.runtime.name" "OpenJDK Runtime Environment",
"java.runtime.version" "11.0.22+7",
"java.vendor" "Eclipse Adoptium",
"java.vendor.url" "https://adoptium.net/",
"java.version" "11.0.22",
"java.vm.name" "OpenJDK Client VM",
"java.vm.version" "11.0.22+7",
"os.name" "Windows 10",
"os.version" "10.0",
"user.language" "en",
"user.timezone" "America/Los_Angeles"}

I think the problem is Metabase v48+ does not run on Windows on H2 · Issue #39040 · metabase/metabase · GitHub

please use a postgres db if you're setting up a production metabase instance

1 Like