⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// $Id: Client.java,v 1.3 2002/12/29 11:15:55 per_nyfelt Exp $

import org.ozoneDB.*;
import java.net.*;


/**
 * Simple client program that accesses an object in a remote or local database
 * server.<p>
 *
 * <i> Note: Do not use this sample to do any benchmarking if you are new to
 * ozone! Use the OO1 sample for that. The code of OO1 is more complex and shows
 * how to use ozone for 'real-world' applications. </i>
 *
 *
 * @author <a href="http://www.softwarebuero.de/">SMB</a>
 * @version $Revision: 1.3 $Date: 2002/12/29 11:15:55 $
 */
class Client {

    public static void main( String[] args ) throws Exception {

        ExternalDatabase db = ExternalDatabase.openDatabase( "ozonedb:remote://localhost:3333" );

        // this is just another way to open the same connection
        // db.open ("localhost", 3333);

        // this would initialize a local database instead of accessing a
        // server remote
        // LocalDatabase db = new LocalDatabase();
        // db.open ("/tmp/db");

        db.reloadClasses();
        System.out.println( "connected..." );

        Bus bus = (Bus)db.createObject( BusImpl.class.getName() );
        System.out.println( "bus:" + bus );
        bus.print();
        db.deleteObject( bus );

        Auto auto = (Auto)db.objectForName( "auto" );
        if (auto == null) {
            auto = (Auto)db.createObject( AutoImpl.class.getName(), OzoneInterface.Public, "auto" );
        }

        // doSomething() returns the database object itself. However, in the
        // client we get a proper proxy object.
        Auto auto2 = (Auto)auto.doSomething( auto );

        System.out.println( "auto:" + auto.getClass() + ", " + auto );
        auto.setAge( new Integer( 3 ) );
        System.out.println( "auto.setAge (3)" );
        // auto and auto2 are proxies of the same object.
        System.out.println( "auto2:" + auto2.getClass() + ", " + auto2 );

        Auto copy = (Auto)db.copyObject( auto );
        copy.setAge( new Integer( 100 ) );
        System.out.println( "\nauto:" + auto );
        System.out.println( "copy:" + copy );

        db.deleteObject( copy );

        db.close();
        System.out.println( "deconnected..." );
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -