The Java Binding

The use of the Java language for an EYEDB binding has been motivated by several reasons:
  1. Java is architecture independent,
  2. Java is valuable for distributed network environment,
  3. Java has a very rich builtin library,
  4. Java is secure,
  5. Java is easier to program than C++.
The Java binding is very close from the C++ binding: the class interfaces are identical, the functionalities are the same; only the language is slightly different.

The previous C++ code is here translated for the EYEDB Java API:
 // connecting to the EyeDB server
 org.eyedb.Connection conn = new org.eyedb.Connection();

 // opening database dbname
 person.Database db = new person.Database(dbname);
 db.open(conn, org.eyedb.Database.DBRW);

 // beginning a transaction
 db.transactionBegin();

 // creating a Person
 Person p = new Person(db);

 // setting attribute values
 p.setCstate(CivilState.Sir);
 p.setName(name);
 p.setAge(age);

 p.getAddr().setStreet("voltaire");
 p.getAddr().setTown("paris");

 // creating two cars
 Car car1 = new Car(db);
 car1.setBrand("renault");
 car1.setNum(18374);

 Car car2 = new Car(db);
 car2.setBrand("ford");
 car2.setNum(233491);

 // adding the cars to the created person
 p.addToCarsColl(car1);
 p.addToCarsColl(car2);

 // storing all in database
 p.store(org.eyedb.RecMode::FullRecurs);

 // committing the transaction
 db.transactionCommit();
As shown in this example, the code is absolutely identical except that that some -> in C++ are replaced by a . character in Java.
The only difference that does not appear in our examples is the object memory management. In the C++ example, one should release all the allocated objects; it is not necessary in Java.

EyeDB manual