KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > odmg > Client


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-2001 by SMB GmbH. All rights reserved.
6
//
7
// $Id: Client.java,v 1.1 2002/05/08 15:03:21 per_nyfelt Exp $
8

9 package test.odmg;
10
11 import java.io.*;
12 import org.odmg.*;
13 import org.ozoneDB.odmg.*;
14
15
16 public class Client {
17     
18     public static Implementation odmg;
19     
20     
21     public static void main( String JavaDoc[] args ) throws Exception JavaDoc {
22         odmg = new OzoneODMG();
23         Database db = odmg.newDatabase();
24         db.open( "ozonedb:remote://localhost:3333", Database.OPEN_READ_WRITE );
25         
26         Transaction tx = odmg.newTransaction();
27         tx.begin();
28         
29         Auto auto = null;
30         try {
31             auto = (Auto)db.lookup( "name" );
32         } catch (Exception JavaDoc e) {
33             auto = new Auto( "Name" );
34             System.out.println( auto.getClass().getSuperclass().getName() );
35             System.out.println( Thread.currentThread().getName() + ": " + auto );
36             db.bind( auto, "name" );
37         }
38         
39         auto.setName( "Trabant" );
40         System.out.println( Thread.currentThread().getName() + ": " + auto );
41         
42         // db.deletePersistent (auto);
43

44         tx.commit();
45         
46         db.close();
47     }
48 }
49
Popular Tags