Search code examples
derby

Troubles with running Derby on OS X in Embedded Mode


I am facing the following problem. Trying to get Derby DB working in Embedded mode on my Macbook, but getting the following error :

java.sql.SQLException: No suitable driver found for jdbc:derby

Derby log shows :
java.vendor=Oracle Corporation
java.runtime.version=1.8.0_65-b17
user.dir=/Users/a1/Documents/
os.name=Mac OS X
os.arch=x86_64
os.version=10.9.4
derby.system.home=null
Database Class Loader started - derby.database.classpath='' 

Seems like trouble with environment variable, getting the following when running setEmbeddedCP in my terminal:

Error: DERBY_HOME is not set. Please set the DERBY_HOME environment variable
to the location of your Derby installation.

The following are contents of bash_profile

export JAVA_HOME=$(/usr/libexec/java_home)
export DERBY_HOME=$(/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/db)

Any ideas? Thanks


Solution

  • DERBY_HOME should be set to the location where you downloaded and unzipped the Derby jar files. That is, $DERBY_HOME/lib/derby.jar should be the location of your derby.jar file.

    Here are some docs: https://db.apache.org/derby/docs/10.12/getstart/tgssetupenvironment.html

    Your actual databases can be located anywhere; they do not have to be located under DERBY_HOME (and typically are not located there). Commonly, your database is located in a folder that is part of the data files for your application (this is known as the "embedded" configuration), or in a folder that is managed by the Derby Network Server (this is known as the "client/server" configuration).

    I recommend working through the entire Derby introduction guide at: https://db.apache.org/derby/docs/10.12/getstart/index.html