Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
support-rkalla
Post subject: [DB] How do I install and connect to Apache Derby?  PostPosted: Jan 23, 2007 - 03:52 PM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23305

The Apache Derby is a great Java-based multi-use database (along with HSQLDB). Both of these databases can be set to run in-memory (embedded) or as a service like a more typical DBMS install. This tip will cover how to install and run Derby in-memory.

This is extremely helpful when testing an application and you need a temporary DB to run all your tests against.

Installing Apache Derby

    1) Go here for the latest stable Derby release and download the BIN ZIP file.
    2) After downloading it, unzip the file to some location (it will create a db-derby-<VERSION>-bin subdirectory)

Believe it or not, now we are done with the installation. Since the DB is going to run in-memory, just making "connect" calls via the embedded JDBC driver will actually create the DB for us, we don't need to do any more installing or initialization.

Connecting to Apache Derby
These instructions look long, but they are very straight forward and most of them you only need to do once...

    1) In MyEclipse, switch to the "MyEclipse Database Explorer" perspective:
    Image
    2) Click the "New" connection button:
    Image
    3) Name the profile (e.g. "Embedded Derby Connection")
    4) Click "Configure database driver"
    5) Click "New..."
    6) Select "Derby" (2nd one from top)
    7) In the "Driver JARs" tab, click "Add JARs..."
    8) Find your derby.jar file in the /lib directory under the derby directory we unzipped from the section above.
    9) Use the "Driver classname" drop-down box to select the org.apache.derby.jdbc.EmbeddedDriver class:
    Image
    10) Hit OK, select Derby and hit OK again (Notice that the Driver on the connection dialog should be "Derby")
    11) Set the URL to jdbc:derby:derbyDB;create=true and leave everything else blank ("derbyDB" is the name of our DB, you can name it anything you want)
    12) Hit Finish

Now you can select the Derby connection and hit the "Open Connection" button to connect to your Derby DB.

Note: Because this DB runs in memory (the way we have set it up) all state of the DB will be lost between disconnect and reconnect. If you need to persist your data to your hard drive or want to setup Derby as a normal server service, please see the Derby Documentation.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits