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!
To connect to the network server via Java code you need to have the derbyclient. jar in your classpath. The network connection string to this database is the IP address of the server:portnumber. For example for a server which is running on localhost you can create a new database via the following string.
Download the Derby database software from the Apache website at http://db.apache.org/derby/derby_downloads.html. Extract the files into the directory that you have created for the Derby database. For example: C:\Derby. Set the DERBY_HOME system variable to the location of your Derby installation.
Right-click the restaurants. sql file in the Package Explorer view and select Apache Derby, Run SQL Script using 'ij'. The Console view shows the SQL commands contained in the file and executing in ij along with the output of the commands.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With