Oracle Berkeley DB Java Edition

I was searching NoSQL databases and see that Oracle provides a NoSQL database called Berkeley DB. I examined it and wrote a blog to give quick tips to start Java Edition of Berkeley DB. This blog was published in Turkish, about 1 year ago. I’ve decided to translate (in fact, re-write) and publish it in English, and this is what you are reading now.

Berkeley DB is a high-performance embedded database originated at the University of California, Berkeley. It’s fast, reliable and used in several applications such as Evolution (email client), OpenLDAP, RPM (The RPM Package Manager) and Postfix (MTA). In contrast to most other database systems, Berkeley DB provides relatively simple data access services. Berkeley DB databases are B+Trees (like indexes in Oracle RDBMS) and can store only key/value pairs (there are no columns or tables). The keys and values are byte arrays. Databases are stored as files within a single directory which is called “environment”.

There are three versions of Berkeley DB:

  • Berkeley DB (the traditional database, written in C)
  • Berkeley DB Java Edition (native Java version)
  • Berkeley DB XML (for storing XML documents)

As a hobbyist Java programmer, I prefer Berkeley DB Java Edition (JE). Berkeley DB JE supports almost all features of traditional Berkeley DB such as replication, hot-backups, ACID and transactions. It is written in pure Java so it’s platform-independent.

Berkeley DB JE provides two interfaces:

  1. Traditional Berkeley DB API (with DB data abstraction of key/value pairs)
  2. Direct Persistence Layer (DPL) which contains “Plain Old Java Objects” (POJO)

Because I’m an old-school (ex)programmer, I’ll show how to use the traditional Berkeley DB API. Traditional Berkeley DB API will help you understand how Berkeley DB works.

How to Install Oracle Grid Control 11g (Step by Step Guide)

Oracle Enterprise Manager Grid Control is a tool to manage and monitor multiple instances of Oracle and non-Oracle platforms such as Microsoft .NET, Microsoft SQL Server, NetApp Filers, BEA weblogic and others.

I’ll show how to install Oracle Grid Control 11g on Oracle Linux (32bit). Here are the main steps:

1) Installation of Oracle Linux (How to Install Oracle Linux 5.6)
2) Installation of Oracle Database 11.2.0.2 (Repository Database)
3) Installation of Java and Weblogic Server (Middleware)
4) Installation of Grid Control
5) Installation of Grid Control Agent to a Target System

Installation of Oracle Database 11.2

After you install Oracle Linux, login as root and create the directories for Grid Control and other software we’ll install:

Because we installed oracle-validated package (How to Install Oracle Linux 5.6), user oracle and the related groups have been already created automatically. Password of the user Oracle is “oracle”. Login as oracle to the system, download the Oracle Database binaries. I’ll use 11.2.0.2 but the steps will be for 11.2.0.1 which you can download from Oracle.com:

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linuxsoft-085393.html

Unzip the files:

For regular 11.2.0.1 (Linux x86):

Unzip will create a directory named “database”, go into this directory and run “./runInstaller”:

How to Install/Update Java (JDK) on Oracle Linux

Oracle Linux uses RPM (Red Hat Package Manager). If you want to install latest Java platform, you can download Java RPM packages from:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Oracle releases Java RPM wrapped in a self-extracting binary file. So instead of using rpm tool, you just change the mode of file, and make it executable and then run it:

Is it done? Let’s check it:…

How to Develop Java Stored Procedures

I’ll try to demonstrate how we can use loadjava to load our Java class into Oracle Database and use its methods as stored procedures. Before we begin to write the Java codes, I’ll create a simple table. When I call my java stored procedure, it will insert a record to this table.

I created this table in HR schema because I’ll load my java object in HR schema. If you’ll use another schema, then do not forget to load your java code in same schema or set required permissions. This is the main method I’ll use as my stored procedure: