1. First Glance

Before diving straight into the first source code samples let's get you familiar with some basics.


    1.1. The db4o engine...

    The db4o object database engine consists of one single jar file. This is all that you need to program against. The versions supplied with the distribution can be found in /db4o-4.0/lib/.

    db4o-4.0-java1.1.jar
    will run with most Java JDKs that supply JDK 1.1.x functionality such as reflection and Exception handling. That includes many IBM J9 configurations, Symbian and Savaje.

    db4o-4.0-java1.4.jar
    is built for all Java JDKs between 1.2 and 5.0.


    1.2. Installation

    If you add one of the above db4o-*.jar files to your CLASSPATH db4o is installed. In case you work with an integrated development environment like Eclipse (We really recommend Eclipse, it's free.) you would copy the db4o-*.jar to a /lib/ folder under your project and add db4o to your project as a library.

    Here is how to add the db4o to an Eclipse project
    - create a folder named "lib" under your project directory, if it doesn't exist yet
    - copy db4o-*.jar to this folder
    - Right-click on your project in the Package Explorer and choose "refresh"
    - Right-click on your project in the Package Explorer again and choose "properties"
    - select "Java Build Path" in the treeview on the left
    - select the "Libraries" tabpage.
    - click "Add Jar"
    - the "lib" folder should appear below your project
    - choose db4o-*.jar in this folder
    - hit OK twice


    1.3. API

    The API documentation for db4o is supplied as JavaDocs in
    db4o-4.0/doc/api/index.html. While you read through this tutorial it may be helpful to look into the API documentation occasionaly. For the start, the packages com.db4o and com.db4o.query are all that you need to worry about.

    Let's take a first brief look at one of the most important interfaces:

    com.db4o.ObjectContainer

    This will be your view of a db4o database:
    - An ObjectContainer can either be a database in single-user mode or a client to a db4o server.
    - Every ObjectContainer owns one transaction. All work is transactional. When you open an ObjectContainer, you are in a transaction, when you commit() or rollback(), the next transaction is started immediately.
    - Every ObjectContainer maintains it's own references to stored and instantiated objects. In doing so, it manages object identities.

    In case you wonder why you only see very few methods in an ObjectContainer, here is why: The db4o interface is supplied in two steps in two packages, com.db4o and com.db4o.ext for the following reasons:
    - It's easier to get started, because the important methods are emphasized.
    - It will be easier for other products to copy the basic db4o interface.
    - We hint how a very-light-version of db4o should look like.

    Every com.db4o.ObjectContainer object also always is a com.db4o.ext.ExtObjectContainer. You can cast to ExtObjectContainer or you can call the #ext() method if you want to use advanced features.




    --
    generated by
    Doctor courtesy of db4objecs Inc.