📄 client.java
字号:
// $Id: Client.java,v 1.3 2003/11/23 15:19:37 per_nyfelt Exp $package odmg;import org.odmg.*;import org.ozoneDB.odmg.*;/** * This simple sample shows how to use the ODMG interface of ozone. The are * a few things in the ozone ODMG interface that are not fully ODMG 3.0 * compliant. So, care must be taken when writing code against this API.<p> * * First, database objects do not implement any database specific interfaces. * This means the actual database connection cannot be simple retrieved by * calling the database() method of the database object. * * * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.3 $Date: 2003/11/23 15:19:37 $ */public class Client { public static ODMG odmg; public static void main( String[] args ) throws Exception { odmg = new OzoneODMG(); EnhDatabase db = (EnhDatabase)odmg.newDatabase(); db.open( "ozonedb:remote://localhost:3333", Database.OPEN_READ_WRITE ); Transaction tx = odmg.newTransaction(); tx.begin(); Bus bus = new Bus( "bus" ); bus.print(); Auto auto = null; try { auto = (Auto)db.lookup( "name" ); } catch (Exception e) { // auto = new AutoImpl ("Name"); auto = (Auto)db.createPersistent( AutoImpl.class ); System.out.println( auto.getClass().getSuperclass().getName() ); System.out.println( Thread.currentThread().getName() + ": " + auto ); db.bind( auto, "name" ); } auto.setName( "Trabant" ); System.out.println( Thread.currentThread().getName() + ": " + auto ); auto.doSomething(); AccessThread t1 = new AccessThread( db, tx ); t1.start(); Thread.sleep( 3000 ); // db.deletePersistent (auto); tx.commit(); db.close(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -