måndag, september 17, 2007

Using Berkeley DB Inside Your JDeveloper Project

Sometimes you need a small database within your JDeveloper project, but you don't want to install any of the usual suspects like Oracle Database 10g Express Edition or Oracle Lite. If so, Oracle Berkeley DB is an ideal candidate. It's very easy to get started with it inside JDeveloper; just follow the steps below, and you will be up and running in just 15 minutes. Start by downloading the Oracle Berkeley DB Java Edition from the OTN:

http://www.oracle.com/technology/software/products/berkeley-db/je/index.html

  1. Create a new Project in JDeveloper
  2. Create a new Library in the JDeveloper project that contains the lib/je-3.2.44.jar file from the Berkeley DB distribution.
  3. Save the Project.
  4. Create a new folder in the file system under the newly created JDeveloper project named: src/collections/hello
  5. In the file system, copy the file examples/collections/hello/HelloDatabaseWorld.java from the Berkeley DB distribution and put it into the src/collections/hello folder.
  6. In JDeveloper, refresh the project. The copied file should now appear in the JDeveloper project under Application Sources.
  7. Create a new directory under your project directory called tmp. This is were the database will reside. If you want to place the database somewhere else, change the line in the HelloDatabaseWorld.java that says:

    String dir = "./tmp";

  8. Run the project inside JDeveloper, the result should be similar to:

    Writing data
    Reading data
    0 Hello
    1 Database
    2 World

If you want to read more about Oracle Berkeley DB Java Edition, please refer to this URL:

http://www.oracle.com/technology/products/berkeley-db/je/index.html

Inga kommentarer:

Skicka en kommentar