H2 Database not found error 90146. H2 database is not created on start
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
H2 error 90146, usually shown as "Database not found", means your application tried to open a database that H2 was told must already exist. In most cases the database is not created on startup because the JDBC URL, startup flags, or file path explicitly prevent automatic creation.
Why H2 Does Not Create the Database
H2 can run in memory or on disk. For file-based databases, the connection URL controls whether a missing database should be created automatically or whether the connection should fail.
A typical file URL looks like this:
If the database files are missing, H2 can create them when the connection opens.
But if your URL includes IFEXISTS=TRUE, H2 refuses to create a new database:
That is one of the most common causes of error 90146.
A Working Example
Here is a minimal Java example that creates a file-based H2 database if it does not already exist:
If ./data/appdb.mv.db does not exist yet, H2 creates it.
Now compare that with a failing URL:
If the file is missing, the connection throws the "database not found" error instead of creating anything.
Check the File Path Carefully
Many startup failures are really path problems. Relative paths are resolved against the current working directory of the Java process, not necessarily the project root you expect.
For example:
may create or look for the database in a different folder depending on:
- your IDE run configuration
- your test runner
- your production process working directory
If you suspect a path issue, try an absolute path temporarily while debugging:
That removes ambiguity and helps confirm whether the error is caused by location rather than creation rules.
Memory Databases Behave Differently
If you use an in-memory H2 database, creation happens automatically when the first connection opens:
In that case, error 90146 usually points to a different configuration mismatch, such as using the wrong URL name or expecting the same in-memory database across separate class loaders or processes.
Spring Boot Configuration Example
A Spring Boot application often configures H2 like this:
If you accidentally add ;IFEXISTS=TRUE, startup can fail before schema initialization runs, because the database connection itself never succeeds.
Common Pitfalls
The biggest pitfall is adding IFEXISTS=TRUE without realizing what it does. That flag is useful when you want to ensure a database has already been provisioned, but it blocks auto-creation.
Another common issue is mixing up relative paths. An H2 URL that works in your IDE can fail in tests or inside a packaged application because the working directory changed.
A third problem is expecting schema creation tools to create the database file itself. Framework features such as schema.sql or JPA DDL generation run only after the database connection is established. They cannot help if H2 refuses to open the database in the first place.
Finally, developers sometimes confuse file-based and in-memory URLs. mem:testdb and ./data/testdb are completely different databases with different lifecycle behavior.
Summary
- Error
90146usually means H2 was asked to open an existing database that is not there. - '
IFEXISTS=TRUEis a common reason H2 does not create the database on startup.' - Check whether your JDBC URL is file-based or in-memory.
- Verify the resolved file path, especially when using relative paths.
- Fix the connection URL first; schema initialization runs only after a successful connection.
Related reading
- H2 in-memory database. Table not found
- Hadoop on cassandra database
- Handling asynchronous database queries in node.js and mongodb
- Has anyone used Hedera Hashgraph? Is it really as fast as 100 ~ 10000/s for transactions?
- Hadoop Distributed Cache don't work
- Hadoop Distributed Cache error message interpretation
- have some one tried running cadence on cockroach db
- Having both a Created and Last Updated timestamp columns in MySQL 4.0

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.