It is not the defrag that fails, it fails when I try to open the connection 
again....

dbConnection = DriverManager.getConnection("jdbc:h2://C:\\H2DB", "user", 
"password");
Statement statement = dbConnection.createStatement();
statement.execute("SHUTDOWN DEFRAG");
dbConnection.close(); //is already closed, but just to be sure...
dbConnection = DriverManager.getConnection("jdbc:h2://C:\\H2DB", "user", 
"password"); //<<<FAILS

The last statement fails with the stack trace I posted...

Op donderdag 6 augustus 2015 10:59:38 UTC+2 schreef sim:
>
> This works for 1.4.188 in my project with no problem
>
> val conn = ds.getConnection
> val stat = conn.createStatement()
> stat.addBatch("set exclusive 2")
> stat.addBatch("shutdown defrag")
> stat.executeBatch()
> conn.close()
>
>
>
>
>
>  
>
> On Thursday, August 6, 2015 at 6:37:26 AM UTC+3, Reinier L'abee wrote:
>>
>> Hi all,
>>
>> I use H2 version 1.4.188 in embeddded mode (mvstore enabled) and when I 
>> execute the statement DEFRAG SHUTDOWN I'm not able to open a new connection 
>> anymore. I use a single connection in my application and that gets closed 
>> when I execute the shutdown statement. (connection.isClosed() returns 
>> true). But when I then I try to open a new connection it tells me the file 
>> is locked. Am I missing something here? I believe this used to work a 
>> couple of months ago. Has something changed, or do I have to review my 
>> code? ;)
>>
>> Caused by: java.lang.IllegalStateException: The file is locked: 
>> nio:C:/H2DB.mv.db [1.4.188/7]
>>     at 
>> org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:773)
>>     at org.h2.mvstore.FileStore.open(FileStore.java:167)
>>     at org.h2.mvstore.MVStore.<init>(MVStore.java:346)
>>     at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2888)
>>     at org.h2.mvstore.db.MVTableEngine$Store.open(MVTableEngine.java:154)
>>     ... 68 more
>> Caused by: java.nio.channels.OverlappingFileLockException
>>     at sun.nio.ch.SharedFileLockTable.checkList(Unknown Source)
>>     at sun.nio.ch.SharedFileLockTable.add(Unknown Source)
>>     at sun.nio.ch.FileChannelImpl.tryLock(Unknown Source)
>>     at org.h2.store.fs.FileNio.tryLock(FilePathNio.java:121)
>>     at 
>> org.h2.mvstore.cache.FilePathCache$FileCache.tryLock(FilePathCache.java:152)
>>     at java.nio.channels.FileChannel.tryLock(Unknown Source)
>>     at org.h2.mvstore.FileStore.open(FileStore.java:164)
>>     ... 71 more
>>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to