0

My test application.yml is below:

 spring:
  datasource:
    url: jdbc:hsqldb:hsql:/localhost:9001/db/test
    driverClassName: org.hsqldb.jdbcDriver
    username: root
    password:
  jpa:
    show-sql: false
    hibernate:
      ddl-auto: create-drop
      use-new-id-generator-mappings: false

Db connection config class is below:

@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
@EntityScan("com.x.project")
@EnableJpaRepositories("com.x.project")
public class DatabaseConfiguration {

    @Value("${spring.datasource.driverClassName}")
    private String driverClassName;

    @Value("${spring.datasource.url}")
    private String url;

    @Value("${spring.datasource.username}")
    private String username;

    @Value("${spring.datasource.password}")
    private String password;

    @Bean
    public DataSource dataSource() {
        return new HikariDataSource(hikariConfig());
    }

    private HikariConfig hikariConfig() {
        HikariConfig config = new HikariConfig();
        config.setDriverClassName(driverClassName);
        config.setJdbcUrl(url);
        config.setUsername(username);
        config.setPassword(password);
        config.setPoolName("my db pool");
        config.setMaximumPoolSize(2);
        return config;
    }
}

As I am new to HSQLDB, I am not sure whether I need to download hsqldb server or not while using URL like jdbc:hsqldb:hsql:/localhost:9001/db.

The error I get is:

Caused by: org.hsqldb.HsqlException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile@2e637605[file =null, exists=false, locked=false, valid=false, ] method: setPath reason: java.io.IOException:

How am I supposed to solve this situation?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Aksoy
  • 91
  • 1
  • 8
  • Does this answer your question? [Database lock acquisition failure and hsqldb](https://stackoverflow.com/questions/3968595/database-lock-acquisition-failure-and-hsqldb) – Anish B. Feb 19 '21 at 13:17
  • Please post the full exception stacktrace – Mark Rotteveel Feb 19 '21 at 13:17
  • your jdbc-url implies hsql usage in "server mode" (alternatives are: "file" and "memory") . the exception message lets assume, that the db is already locked. (by a running/obsolete process) – xerx593 Feb 19 '21 at 13:19
  • @xerx593 if the usage in server mode, should I download hsqldb server and run from cmd ? (because I already tried it but couldnt solve it). I just run from intellij, but what could lock the db when the only connector is intellij ? – Aksoy Feb 19 '21 at 13:33
  • if you are asking like that: 1. You should use file/in-memory mode!;) 2. Kill (unidentified java) processes, clean up file system (`db/test` might be somewhere) ... [baledung has an article](https://www.baeldung.com/spring-boot-hsqldb), which shows how to use it in "standalone/server mode", for embedded usage you just need to change the url ( section 3.2 ...and *don't* start a server, but just package the jar into embedding application). – xerx593 Feb 19 '21 at 14:42

0 Answers0