Where are my H2 database files?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 00:28:08

问题


I'm just evaluating the H2 database... I downloaded and unpacked the installation and connect to a database at jdbc:h2:file:/home/konrad/test. /home/konrad is my home dir, test does not exist (I expect H2 to create it).

The console seems to work OK. I created a table and inserted a row to it. Even if I disconnect and reconnect the console, I can see and query the table.

However, I don't see the file I expected. Where is it?


回答1:


Are you sure there is no:

/home/konrad/test.h2.db

file? If not, try this:

$ lsof -p `jps -ml | grep h2 | cut -d' ' -f1` | grep \.h2\.db$

What it does is it look for Java process of H2 console, grabs its PID and lists all open files of that process, filtering by H2 database extension. Of course you can use PID of any other Java process accessing this DB. If it is persisted on the disk, you can't miss it.




回答2:


Your database files can be found in your user directory. For windows

C:\Users\<userName>

Take a look at H2's FAQ, You can find more information here

And in new versions of Spring, it's located simply in project root directory, like this :

And property is spring.datasource.url=jdbc:h2:file:./fileOrDbName



来源:https://stackoverflow.com/questions/6397716/where-are-my-h2-database-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!