To use this client, you must first compile it using a standard Makefile, as follows (replace <<datadir>>
with the data directory, usually /usr/share
):
include <<datadir>>/eyedb/Makefile.eyedb all: PersonTest.class person/Database.java: schema.odl $(EYEDB_ODL) --gencode=Java --package=person --output-dir=person $< PersonTest.class: PersonTest.java person/Database.java CLASSPATH=$(EYEDB_CLASSPATH):. javac *.java person/*.java
Once compiled, you can execute the program as follows:
% CLASSPATH=. eyedbjrun PersonTest person_g
The eyedbjrun script is a helper script that wraps the call to the Java
virtual machine with an appropriate CLASSPATH environment variable containing the path to eyedb.jar
and passes the necessary options to the PersonTest
class.
A few remarks about the Java code:
all operations - setting, getting attributes, storing, querying instances in a database - must be performed within a transaction. A transaction is initiated using the Database::transactionBegin
method and is committed (resp. aborted) using the Database::transactionCommit
(resp. Database::transactionAbort
) method.
to store any instance in the database, you need to call the store
(or realize
) method on this instance. In our case, we use the argument FullRecurs
indicating that we want all related instances (through relationship or indirect attribute) to be stored in the database.
The Java binding support both the standalone applications and the applets.
To have more information about the Java binding, please refer to the EyeDB Java binding manual.