Intellij嵌入式H2数据库表未出现
我正在创建一个Spring Boot应用程序,并且我正在使用Intellij的嵌入式H2数据库。
我已经在我的应用程序中添加了以下行。Properties文件:
spring.datasource.url=jdbc:h2:~/testdb;MV_STORE=false;AUTO_SERVER=TRUE
尽管连接成功,我可以使用Intellij的查询控制台查询数据库,但表不显示在数据库选项卡中。
Succeeded
DBMS: H2 (ver. 2.1.210 (2022-01-17))
Case sensitivity: plain=upper, delimited=exact
Driver: H2 JDBC Driver (ver. 2.1.210 (2022-01-17), JDBC4.2)
Ping: 16 ms
当我刷新连接或转到数据源配置的“架构”选项卡时,我会收到以下错误:
[42S02][42102] org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "INFORMATION_SCHEMA_CATALOG_NAME" not found; SQL statement: select CATALOG_NAME from INFORMATION_SCHEMA.INFORMATION_SCHEMA_CATALOG_NAME [42102-210].
I'm creating a Spring Boot application and I'm using Intellij's embedded h2 database.
I have added the following lines in my application.properties file:
spring.datasource.url=jdbc:h2:~/testdb;MV_STORE=false;AUTO_SERVER=TRUE
This is my data source configuration
Although the connection is successful and I can query the database using Intellij's query console, the tables do not appear in the Database tab.
Succeeded
DBMS: H2 (ver. 2.1.210 (2022-01-17))
Case sensitivity: plain=upper, delimited=exact
Driver: H2 JDBC Driver (ver. 2.1.210 (2022-01-17), JDBC4.2)
Ping: 16 ms
When I refresh the connection or go to the schemas tab of the data source configuration, I get the following error:
[42S02][42102] org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "INFORMATION_SCHEMA_CATALOG_NAME" not found; SQL statement: select CATALOG_NAME from INFORMATION_SCHEMA.INFORMATION_SCHEMA_CATALOG_NAME [42102-210].
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过转到数据源的高级选项卡并单击专家选项,向我们提供了一个标记为“使用JDBC Metadata Intospect”的复选框,
通过选中该框,成功出现在数据库选项卡中
a href =“ https://i.sstatic.net/vlfrd。” rel =“ noreferrer”>
关于为什么起作用的原因,这是从官方文档中获取的:
https://www.jetbrains.com/help/datagrip /Data-sources-and-drivers-dialog.html
使用JDBC元数据
切换到基于JDBC的Introspector。可用于所有数据库。
为了检索有关数据库对象(DB元数据)的信息,Datagrip使用以下内在范围:
本机内外的人(对于某些DBMS可能无法使用)。本机内外的人使用DBMS特异性表和视图作为元数据的来源。它可以检索DBMS特定的详细信息并产生数据库对象的更精确的图片。
一个基于JDBC的内陆器(可用于所有DBMS)。基于JDBC的Introspector使用JDBC驱动程序提供的元数据。它只能检索有关数据库对象及其属性的标准信息。
当天然内陆器失败或不可用时,请考虑使用基于JDBC的直射器。
当您的数据库服务器版本比Datagrip支持的最小版本年龄时,本机内外的人可能会失败。
您可以尝试切换到基于JDBC的Introspector,以通过从数据库中检索数据库结构信息来解决问题。例如,当数据库工具窗口中未显示数据库或数据库对象中存在的模式时。
By going to the advanced tab of the data source and clicking on expert options, we are presented with a checkbox labeled "Introspect using JDBC metadata"
By checking that box, the tables successfully appear in the Database tab
Regarding why this works, this is taken from the official documentation:
https://www.jetbrains.com/help/datagrip/data-sources-and-drivers-dialog.html
Introspect using JDBC metadata
Switch to the JDBC-based introspector. Available for all the databases.
To retrieve information about database objects (DB metadata), DataGrip uses the following introspectors:
A native introspector (might be unavailable for certain DBMS). The native introspector uses DBMS-specific tables and views as a source of metadata. It can retrieve DBMS-specific details and produce a more precise picture of database objects.
A JDBC-based introspector (available for all the DBMS). The JDBC-based introspector uses the metadata provided by the JDBC driver. It can retrieve only standard information about database objects and their properties.
Consider using the JDBC-based intorspector when the native introspector fails or is not available.
The native introspector can fail, when your database server version is older than the minimum version supported by DataGrip.
You can try to switch to the JDBC-based introspector to fix problems with retrieving the database structure information from your database. For example, when the schemas that exist in your database or database objects below the schema level are not shown in the Database tool window.