Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

jdbc

derby

I am new to Apache Derby database,

When i am trying to crate new database using the following command i am getting the below problem

C:\>java org.apache.derby.tools.ij
ij version 10.10
ij> connect 'jdbc:derby:Mynewdb;create=true';
Mon Mar 03 20:17:32 IST 2014 Thread[main,5,main] java.io.FileNotFoundException: derby.log
(Access is denied)
----------------------------------------------------------------
Mon Mar 03 20:17:33 IST 2014:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.10.1.1 - (1458268): instance a816c00e-0144-886a-02f2-000000b8d0b0
on database directory C:\Mynewdb with class loader sun.misc.Launcher$AppClassLoader@11b86e7
Loaded from file:/C:/db-derby-10.10.1.1-bin/db-derby-10.10.1.1-bin/lib/derby.jar
java.vendor=Sun Microsystems Inc.
java.runtime.version=1.6.0_23-b05
user.dir=C:\
os.name=Windows 7
os.arch=x86
os.version=6.1
derby.system.home=null
Database Class Loader started - derby.database.classpath=''
like image 614
ashok_p Avatar asked Mar 03 '14 14:03

ashok_p


People also ask

How do I connect to Apache Derby database?

Start the JVM. Load the appropriate driver. Create a connection by providing a valid database connection URL.

How do I connect to Derby database in eclipse?

Choose Window > Preferences from the menu to open the Eclipse Preferences dialog. Navigate to Connectivity > Driver Definitions. Select the Derby 10.2 folder and click Add.... In the New Driver Definition dialog, select Derby Client JDBC Driver and click OK.

Can I delete Derby log?

The bottom line: Never delete or manipulate *ANY* files in a Derby database directory structure. Doing so will corrupt the database. The problem: Some Derby users have discovered that deleting the files in the log subdirectory of the database will silence recovery errors and allow access the database.

What is Derby log file?

The derby. log file is created when the Derby server is booted. The network server records the time and version. If a log file exists, it is overwritten, unless the property derby. infolog.


2 Answers

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';

like image 55
hmjd Avatar answered Sep 19 '22 12:09

hmjd


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.

like image 42
Bill Avatar answered Sep 18 '22 12:09

Bill