I'm running a Glassfish 4.1 server with a H2 database in tcp/multi-user mode. I'm trying to programmatically update tables within a singleton bean. I always get the following exception:
org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "GLOBALS"; SQL statement: ALTER TABLE "PUBLIC".GLOBALS ADD STARTFLAG VARCHAR(512) [50200-176]
I know that the table is locked, since one of the container-managed entity managers seems to have an open connection on that table. But at the time of the alter table statement, there would be no need for any connection...
Therefore I am wondering if there is any possibility to close all jdbc connections using container-managed JPA ?
Here's the initialization string I am using to start/connect to the H2 database:
jdbc:h2:tcp://localhost/~/datastore/database;AUTO_SERVER=TRUE;MVCC=TRUE
I already tried to close the container-managed entity manager and the entity manager factory (but I think this is not the correct approach, since it's handled by the container) before the update statements are executed.
I tried to detach the managed objects before the update statements are executed.
I tried to add the MVCC=TRUE option (multi version concurrency).
Also tried to set FILE_LOCK=NO, but then I get another exception which tells me that this combination of options is not valid.
but without success so far...
Any ideas highly appreciated - thanks in advance!