We have a simple Java application developed using Spring Batch framework to load the data that we receive in form of files into the database. We have used H2 database to store the statistics of how many records read/loaded/failed. We get situations where we are required to load multiple files into different tables at same time, that means, running multiple instances of the same Jar file. The problem is, H2 database doesn't provide more than one connection at a time and it repeatedly throws the File is locked exception when running the second instance.
Platform: AIX
Java Version: 1.8
H2 DB Version: 1.4.193
H2 Config in application.properties
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:./h2/DataLoaderApp
spring.datasource.username=sa
spring.datasource.password=
I have tried different solutions but nothing seems to work at all.
Try 1: This did not work
Try 2: Appended FILE_LOCK=NO, it still throws File Locked exception though I do not see the *lock.db file being created.
Please help me out, Thanks a lot for your time.