Error in Intelij h2 config The write format 1 is smaller than the supported format 2, spring boot app
Asked Answered
G

6

20

While trying to connect H2 data source by URL in Intelij, following error occurs:

The write format 1 is smaller than the supported format 2
Genome answered 11/4, 2022 at 15:20 Comment(0)
G
16

Switching to the right version fixed my problem.

To fixed it in Intelij, version of H2 driver should be changed as following config: In the Intelij, click on Data source config then in Drivers tab select H2 database. enter image description here

Genome answered 11/4, 2022 at 20:38 Comment(2)
switching to the right version, resolved my issue. many thanksQua
So how can I get that page..?Vange
C
4

H2 2.*.* cannot open database files created by H2 1.4.200 or older versions, you need to export them to SQL with the version that was used to create these files into SQL script (for example, with SCRIPT TO 'filename.sql' command), create a new database with the new version of H2 and populate it with data from this script (for example, with RUNSCRIPT FROM 'filename.sql' FROM_1X command).

See also the documentation: https://h2database.com/html/tutorial.html#upgrade_backup_restore

H2 2.*.* has a helper class org.h2.tools.Upgrade, it can be used by applications to upgrade their databases.

There is also a third-party upgrade tool: https://github.com/manticore-projects/H2MigrationTool

Casarez answered 11/4, 2022 at 15:49 Comment(0)
H
1

Unless your h2 version is not specified in your pom.xml, select in @Tohid Makari print the version used in your pom.xml. Otherwise you can select "Latest version"

Hillside answered 9/10, 2022 at 17:1 Comment(0)
O
1

Just try to test the connection and then you will get the below error and error itself says what version it needed and what version is provided. So just set the H2 driver version which is expected.

DBMS: H2 (ver. 1.4.200 (2019-10-14)) Case sensitivity: plain=upper, delimited=exact Driver: H2 JDBC Driver (ver. 1.4.200 (2019-10-14), JDBC4.1) [HY000][50000] General error: "The write format 1 is smaller than the supported format 2 [2.1.210/5]" [50000-210] The write format 1 is smaller than the supported format 2 [2.1.210/5].

In My case current set version was 2.1.210 but expected version is 1.4.200.

After updating version in IntelliJ now connection test is successful.

Ovation answered 30/3, 2023 at 8:46 Comment(0)
B
1

Another cause for this error might be a false url. This happened to me when I copied my config from ProjectA to ProjectB and failed to change the url.

Was

spring:
  datasource:
    url: jdbc:h2:file:./projectA/data

Should have been

spring:
  datasource:
    url: jdbc:h2:file:./projectB/data
Bookbinder answered 25/4, 2023 at 14:51 Comment(0)
W
0

This could happen too if you update Spring Boot and your previous database is in version1 (h2 runtime database for test purposes by example). If this is your case you can search your database file (C:\Users\user\databasename.mv.db) and delete it to regenerate (Or update it)

org.h2.jdbc.JdbcSQLNonTransientConnectionException: Versión del archivo de base de datos no soportada ó encabezado de archivo invalido en archivo "C:/Users/user/test.mv.db"
Unsupported database file version or invalid file header in file "C:/Users/user/test.mv.db" [90048-214]
Wriest answered 22/5, 2023 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.