Embedding a Derby database

Derby can serve as an embedded relational database in Java applications. This may be a solution for use cases that need real-time access to relatively stable data, such as gene aliases and annotations. Getting Derby to work within a Cytoscape plugin was not trivial, so I wanted to share that experience.


Getting It To Work

  1. Like other libraries to be included in a plugin, you have to unjar the classes and include them in your build folder.
  2. In order to get my application running, I needed to include both derby.jar and derbytools.jar. Leaving the other out helps keep the size down. These two jars add ~2.3MB.
  3. One of the classes in derby.jar throws an exception while the plugin is being loaded by Cytoscape. EmbeddedActivator.class (org.apache.derby.osgi) implements BundleActivator.class which is not included in the Derby distribution.

    1. Turns out this class is part of an "optional" OSGi package which is under a proprietary license, not Apache!
    2. Rather than going down that dark and treacherous road, I simply removed the osgi folder containing only the EmbeddedActivator class and jared the remaining classes along with my plugin. No problems.

Materials

Here is a sinlge jar file containing derby.jar plus derbytools.jar minus the offending class: derby-slim.jar

And here is sample code for your build.xml to unjar and include the derby classes in your build file:

   1 <unjar overwrite="Yes" dest="${build}">
   2     <fileset dir="${lib.derby}">
   3         <include name="lib/derby-slim.jar"/>
   4     </fileset>
   5 </unjar>
   6 

Next


Comments

Embedding_a_Derby_database (last edited 2009-02-12 01:03:13 by localhost)

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux