Search code examples
javajdbchsqldb

Database lock acquisition failure with hsqldb


I'm running this as an in-process connection, using this JDBC URL:

jdbc:hsqldb:file:C:\Program Files\360Works\SyncData2_MirrorSync\Configurations\3d0c6a29-294b-4a24-b075-70302345fdb5\mirrorsync

I am getting this error, even after completely rebooting the computer:

java.util.concurrent.ExecutionException: java.sql.SQLException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile@e27ecaee[file =C:\Program Files\360Works\SyncData2_MirrorSync\Configurations\3d0c6a29-294b-4a24-b075-70302345fdb5\mirrorsync.lck, exists=true, locked=false, valid=false, ] method: checkMagic magic: '0000000000000000'

How can I fix this?


Solution

  • You can access HSQLDB database that has lock by:

    1- updating my-db-name.properties file and add:

    hsqldb.lock_file=false
    

    2- or removing my-db-name.lck file.

    3- or connect to the database using pass the properties as parameters:

    #Without Sqltool:
        java -cp [jar-path]/hsqldb-2.4.0.jar --inlineRc=url=jdbc:hsqldb:file:/[my-db-file-path]/[db-name];readonly=true;hsqldb.lock_file=false,user=sa
    
    #With Sqltool
        java -cp [jar-path]/hsqldb-2.4.0.jar:[jar-path]/sqltool-2.4.0.jar org.hsqldb.cmdline.SqlTool --inlineRc=url=jdbc:hsqldb:file:/[my-db-file-path]/[db-name];readonly=true;hsqldb.lock_file=false,user=sa
    

    Other HSQLDB database parameters can be found here, however note that only few of them can be updated after first time. http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html