apache Derby - getting java.io.FileNotFoundException: derby.log (Access is denied) when creating new database

A file named derby.log will be created in the current working directory when you run ij (or attempt to use embedded Apache Derby in some other application). From the post, it appears you are executing this from C:\ and the user you are logged on as does not have write access to that directory: change to a directory where the user has permission to create a file and retry.

Note it is possible to suppress this log file (though I have not yet done this myself). See Getting rid of derby.log. However, suppressing the log file would just result in another failure in your case because the database will be created on the file system relative to the current directory. That is, an attempt to create the directory named Mynewdb in the current directory, C:\, would also fail for the same reason. It is possible to specify a path for the database to avoid creating in the current working directory:

ij> connect 'jdbc:derby:/tmp/test_db;create=true';


user.dir=C:\

os.name=Windows 7

Windows 7 (and up?) doesn't let you write files to the root directory in most cases. You should cd to another directory before starting ij. e.g. cd \Users\YOUR_USER_NAME and you should be good to go.

Tags:

Java

Jdbc

Derby