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

后端 未结 13 1118
时光取名叫无心
时光取名叫无心 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:20

    I ran into similar problems running with ORMLite from a web application. I initially got stuck on the syntax to use server mode in the url. The answers above helped with that. Then I had the similar user/password error which was easier to figure out. I did not have to shut anything down or erase any files. The following code worked:

    protected ConnectionSource getConnectionSource() throws SQLException {
        String databaseUrl = "jdbc:h2:tcp://localhost/~/test";
        return new JdbcConnectionSource(databaseUrl,"sa","sa");
    }
    

    To use H2 in server mode on wildfly, I Modifed connection-url in standalone.xml

    
         jdbc:h2:tcp://localhost/~/test
    

提交回复
热议问题