What is the proper way to close H2?

前端 未结 5 1945
我在风中等你
我在风中等你 2020-12-15 04:25

This is related to this post.
I think I am having problem with H2 meaning that it does not close properly.
I suspect this since I see myDB.lock.db

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 05:01

    By looking at the DbStarter.contextDestroyed()'s code (thanks to Allan5's answer), here is the code that will work:

    connection.createStatement().execute("SHUTDOWN");
    

    So Aaron Digulla's answer was correct (even if not fully "copy/pastable").

    Moreover, if you have started an H2 TCP server using server = Server.createTcpServer("-tcpAllowOthers"), you can stop it simply using server.stop().

提交回复
热议问题