Intellij IDEA and H2 DB file recognition problem
Answered
Hi, i have little problems with my IntelliJ config. I am creating project using H2 1.4.192 version as embedded data source. So H2 since version 1.4.X storage as default data in file with extension .mv.db. First my problem is that my database tool don't recognize this type of data source. I can only add H2 data source with extension *.h2.db. My question is how can i fix it. The next problem how can i set file with this extension (.mv.db) to be recognized by intellij as Data Source. Files with extension *.db everything works fine. I looked for a solution in file types option tab, but there is not in "Recognized File Types" Data Source option.
Please sign in to leave a comment.
Hello Peter,
When you enter connection URL in for H2 Data Source correctly everything should work without need to additionally configuring any extensions in IDE. What connection settings are you specifying? Thanks.
I configured my data source in persistence.xml files. To be exact i have 2 persistence.xml one configured in test purpose with H2 and one with postgresql. The data source (H2) in intellij looks like this (this is the file test.mv.db and i cannot do anything with this) :
persistence.xml in test directory:
https://gist.github.com/hadson172/94c3d3f69151ecada5244ac93a983ca0
Sorry for delayed reply.
>this is the file test.mv.db and i cannot do anything with this
When I added persistence.xml with persistence-unit from the gist and re-opened the project - IDE discovered new Data Source and offered to create it in the project:
There was an issue with the file path in the created data source, though, which I had to correct to a full path (this is due to this bug https://youtrack.jetbrains.com/issue/DBE-2804 ). After specifying full path to a file it works for me:
Could you please check if it works for you? Thanks.
I did in the way you said. It works but not completly. Check this out:
After this if you checkout db folder you see something like this:
IntelliJ instead connecting to test.mv.db create new data source test.h2.db. So it even from persistence.xml refuse to create db with appropriate extension. (don't pay attention to test.trace.db it is a file not connected with this problem - bug in code).
EDIT:
Found source of the problem. I had in maven dependency the newest version of H2 DB but in Data Source Manager driver wasnt up to date version. After i downloaded the newest IntelliJ connected to test.mv.db. But still intelliJ doesn't recognize test.mv.db as Data Source but as unknown file. It is not comfortable to switch persistence.xml file in module option only to add Data Source. Thanks for your help ;)
Thanks for the information! I've filled two enhancement requests, please feel free to vote and follow them:
https://youtrack.jetbrains.com/issue/DBE-3272
https://youtrack.jetbrains.com/issue/IDEA-162549