H2 database error: Database may be already in use: “Locked by another process”

后端 未结 13 1116
时光取名叫无心
时光取名叫无心 2020-12-12 23:52

I am trying to use the H2 database from a Java application.

I created the database and its tables through the H2 Console and then I try to connect from Java using <

13条回答
  •  自闭症患者
    2020-12-13 00:22

    I had the same problem. in Intellj, when i want to use h2 database when my program was running i got the same error. For solve this problem i changed the connection url from

    spring.datasource.url=jdbc:h2:file:~/ipinbarbot
    

    to:

    spring.datasource.url=jdbc:h2:~/ipinbarbot;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
    

    And then my problem gone away. now i can connect to "ipinbarbot" database when my program is. If you use Hibernate, also don't forget to have:

    spring.jpa.hibernate.ddl-auto = update
    

    goodluck

提交回复
热议问题