1 package odmg; 3 4 import org.odmg.*; 5 import org.ozoneDB.odmg.*; 6 7 8 21 public class Client { 22 23 public static ODMG odmg; 24 25 26 public static void main( String [] args ) throws Exception { 27 odmg = new OzoneODMG(); 28 29 EnhDatabase db = (EnhDatabase)odmg.newDatabase(); 30 db.open( "ozonedb:remote://localhost:3333", Database.OPEN_READ_WRITE ); 31 32 Transaction tx = odmg.newTransaction(); 33 tx.begin(); 34 35 Bus bus = new Bus( "bus" ); 36 bus.print(); 37 38 Auto auto = null; 39 try { 40 auto = (Auto)db.lookup( "name" ); 41 } catch (Exception e) { 42 auto = (Auto)db.createPersistent( AutoImpl.class ); 44 System.out.println( auto.getClass().getSuperclass().getName() ); 45 System.out.println( Thread.currentThread().getName() + ": " + auto ); 46 db.bind( auto, "name" ); 47 } 48 49 auto.setName( "Trabant" ); 50 System.out.println( Thread.currentThread().getName() + ": " + auto ); 51 52 auto.doSomething(); 53 54 AccessThread t1 = new AccessThread( db, tx ); 55 t1.start(); 56 57 Thread.sleep( 3000 ); 58 59 61 tx.commit(); 62 63 db.close(); 64 } 65 } 66 | Popular Tags |