I have a Derby database that is giving me a read-only error. The database was working fine, up until last week when disk ran out of space:
Caused by: java.io.IOException: No space left on device
at java.io.RandomAccessFile.writeBytes0(Native Method)
at java.io.RandomAccessFile.writeBytes(RandomAccessFile.java:520)
at java.io.RandomAccessFile.write(RandomAccessFile.java:550)
at org.apache.derby.impl.store.raw.log.LogAccessFile.writeToLog(Unknown Source)
at org.apache.derby.impl.store.raw.log.LogAccessFile.flushDirtyBuffers(Unknown Source)
... 23 more
I cleaned up disk and there are 80% of disk is freed for derby. But the derby is still in read-only mode:
java.sql.SQLException: An SQL data change is not permitted for a read-only connection, user or database.
org.apache.derby.impl.jdbc.EmbedSQLException: An SQL data change is not permitted for a read-only connection, user or database.
org.apache.derby.iapi.error.StandardException: An SQL data change is not permitted for a read-only connection, user or database.
I found there is a db.lck file (which file size is 0) there, can I remove that file? Is there any other way to change it read/write mode? Thank you!
The reason I got the SQL error was due to a lock file owned by root. I found it in the .artifactory/derby
directory, it was called db.lck
, and removing it got artifactory to start up just fine again.
We run artifactory under Tomcat, and the .artifactory directory was in the home directory of the user that started Tomcat.
I cleaned up disk but I didn't reboot my java process which connected to derby. I killed the process and restarted it, derby is in read/write mode.
来源:https://stackoverflow.com/questions/25747227/how-can-change-derby-to-read-write-mode