Intelij H2配置中的错误写入格式1小于支持格式2,Spring Boot应用
在尝试连接H2
url In intelij中的数据源时,发生错误以下错误:
The write format 1 is smaller than the supported format 2
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
切换到正确的版本解决了我的问题。
要在Intelij中修复它,
h2
驱动程序的版本应如下config更改:在Intelij中,单击数据源配置,然后在驱动程序选项卡中选择H2数据库。
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.
H2 2。*。*无法打开由H2 1.4.200或以上版本创建的数据库文件,您需要将其导出到SQL,并使用用于将这些文件创建到SQL脚本的版本(例如,使用
script to to to 'filename.sql'
命令),创建一个带有新版本的H2的新数据库,并使用此脚本中的数据填充它(例如,使用runscript来自'filename.sql'from_1x
>命令)。另请参阅文档:
https://h2database.com.com.com.com.com/html/html/html/tutorial.html.html#upgradeup_backup_backp_backp_backebackp_restore </
22222 *。*有一个助手类
org.h2.tools.upgrade
,应用程序可以使用它来升级其数据库。还有一个第三方升级工具:
https://github.com/manticore-projects/h2migrationtool
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, withRUNSCRIPT 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
除非您的 pom.xml 中未指定您的 h2 版本,否则请在 @Tohid Makari 中选择打印 pom.xml 中使用的版本。否则您可以选择“最新版本”
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"
只需尝试测试连接,然后您就会获得以下错误和错误本身说明其需要的版本以及提供的版本。
因此,只需设置预期的H2驱动程序版本即可。
DBMS:H2(VER。1.4.200(2019-10-14))案例灵敏度:plain = upper,Delimited =精确驱动程序:H2 JDBC驱动程序(VER。1.4.200(2019-10-14),JDBC4.1)
[HY000] [50000]一般错误:“写格式1小于受支持的格式2 [2.1.210/5]” [50000-210]写入格式1小于支持的格式2 [2.1.210/ 5]。
在我的情况下,当前设置版本为2.1.210,但预期版本为1.4.200。
在Intellij中更新版本后,Now Connection测试成功。
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.
导致此错误的另一个原因可能是 URL 错误。
当我将配置从 ProjectA 复制到 ProjectB 并且无法更改 url 时,就发生了这种情况。
曾经
应该
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
Should have been
如果您更新Spring Boot并且您以前的数据库在版本1中(H2 Runtime Database用于测试目的),则可能会发生这种情况。如果是您的情况,您可以搜索数据库文件(C:\ User \ User \ user \ databasename.mv.db),并将其删除以再生(或更新)
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)