Saving in-memory H2 database to disk

后端 未结 2 1915
灰色年华
灰色年华 2021-01-01 16:28

How can I save/load full embedded h2 in-memory database to some file or directory in binary mode for faster loading.

I want to use this for caching data so I don\'t

2条回答
  •  走了就别回头了
    2021-01-01 17:15

    As I found out it is possible to use H2 virtual FS that is much faster then default FS. So, I do this way:

    //to save dump
    connection.prepareStatement("SCRIPT TO 'memFS:data.sql'").execute();
    //to load dump
    connection.prepareStatement("RUNSCRIPT FROM 'memFS:data.sql'").execute();
    

提交回复
热议问题