JetBrains / jetbrains_guide

JetBrains Guides where Developer Advocacy and the community share ideas.
Other
164 stars 49 forks source link

No H2 version 2 support #215

Closed yabets closed 1 year ago

yabets commented 2 years ago

Intellij 2021.3.1 Ultimate does not have Provided Driver for H2 above version 1.4.200. Customs jar(h2-2.0.206.jar) will pass Test Connection but cannot open the database file. It fail with the following error message: [42S02][42102] org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CATALOGS" not found; SQL statement: select CATALOG_NAME from INFORMATION_SCHEMA.CATALOGS [42102-206]

I am able to access the database from H2 console. This is an issue from IntelliJ Database navigation tool.

SubOptimal commented 2 years ago

How have you set up the new H2 jar? Which H2 version was used to create your database file?

Following steps worked for me.

  1. create a test database
    
    $ echo "quit" | java -cp /tmp/h2-2.0.206.jar org.h2.tools.Shell -url "jdbc:h2:/tmp/test" -user "sa"

Welcome to H2 Shell 2.0.206 (2022-01-04) Exit with Ctrl+C Commands are case insensitive; SQL statements end with ';' help or ? Display this help list Toggle result list / stack trace mode maxwidth Set maximum column width (default is 100) autocommit Enable or disable autocommit history Show the last 20 statements quit or exit Close the connection and exit

sql> Connection closed


2. connect using the H2 console
```console
$ java -jar /tmp/h2-2.0.206.jar

image image

  1. disconnect from the H2 console
  2. configure the H2 driver to use the version 2.0.206 jar, I removed the old version provided by IntelliJ and added the new version image
  3. set up the connection image
SubOptimal commented 2 years ago

Some addition to my former comment.

The issue happen when IntelliJ tries to fetch the table names, using the statement

SELECT CATALOG_NAME FROM INFORMATION_SCHEMA.CATALOGS

this statement is only supported for H2 1.4.200 and older.

image

As workaround to use IntelliJ with newer H2 drivers the old behavior can be activated by adding OLD_INFORMATION_SCHEMA=TRUE to the connect string.

image

image

maartenba commented 2 years ago

Linking the related issue in the IntelliJ IDEA tracker: https://youtrack.jetbrains.com/issue/IDEA-287220

Is it okay to close the current GitHub issue, as this repository is not directly about product bugs?

tjlee commented 1 year ago

Also, the original issue https://youtrack.jetbrains.com/issue/IDEA-287220 is fixed now. I think we need to close GitHub issue too.