How to Install Derby

Photo by Marek Piwnicki on Unsplash

Derby is a relational database management system developed by Apache. It can be embbedded in Java programs and used for online transaction processing.

Personally, If I have to use RDMS in my personal projects, mostly time I prefer use Derby to other RDMS because it’s incredibly light, extremely practical and has easy installation therefore I want to tell how to install and use in your local environment.

I will tell step by step to this topic because I think that this way will be very useful and if you might be taking error, you can easily fix your problem then can jump to other step.

Step 1: Download JDK

Java Runtime Environment(JRE) is enough to run Derby but I will write some codes that contains JDBC API examples and more in this essay’s last part therefore you must have Java Development Kit (JDK) for run java application.

You can see many Oracle’s various JDK and JRE versions in here. I suggest that you should choose latest version because generally many things is easier than old versions, contains more features and contains more practical things…

Step 2: Install JDK

If you downloaded any JDK, you can easily install it just by click next button

Step 3: Set Environment Variables

Java is installed to the following path. Copy this path

Go to environment variables and click the “New” button and add to JAVA_HOME along with copied path

The other one, your copied path should be added to “Path”.

Well, let’s check everything is ok. Open the Command Line Interface and write in the following command

java --version

if everything is ok, you see like in the following.

Step 4: Download Derby

Please be careful, You must choose correct Derby’s version by have JDK because some Derby versions doesn’t work with some JDK versions.

Step 5: Set Environment Variables for Derby.

In fact, the same steps with JDK. Add DERBY_HOME to System Variables then your add DERBY_HOME along with “bin” folder to inside path

The other one, you should add %DERBY_HOME%\bin to Path inside System Variables like in the following

Step 6: Is Everything Correct

Enter the ij to Command Line Interface. ij is an interactive SQL scripting tool that comes with Derby. It can be used with the Derby Embedded JDBC driver or with a client JDBC driver, such as the Derby Network Client.

And let’s create an DB that name is zoo.​​

connect ‘jdbc:derby:zoo;create=true’;

Let’s Do Some Practices

I want to create a DB that name is coffee and this coffee DB contains one table which name is types and types table contains three any records.

We can use following commands for running our class

javac -cp <YOUR_DERBY_HOME_PATH>\lib\derby.jar;. CoffeeInitializer.javajava -cp <YOUR_DERBY_HOME_PATH>\lib\derby.jar;. CoffeeInitializer

We created our db that name is coffee and related table that name is types. Additionally, We added some records with INSERT commands. Now let’s see our created records with following codes.

You can use following commands for run class

javac -cp <YOUR_DERBY_HOME_PATH>\lib\derby.jar;. CoffeeFetcher.javajava -cp <YOUR_DERBY_HOME_PATH>\lib\derby.jar;. CoffeeFetcher

I hope everything is clear for you. If you don’t understand any part, please feel free to ask. Additionally, I’ve used various resources for prepare this essay. I indicated in following. You can check out.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store