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

📄 client.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: Client.java,v 1.10 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.test.multiple_access;import org.ozoneDB.*;import org.ozoneDB.core.*;import org.ozoneDB.test.*;class AccessThread extends Thread {    ExternalDatabase db;            public AccessThread( ExternalDatabase _db ) {        db = _db;    }            public void run() {        try {            Garage garage = (Garage)db.objectForName( "MG" );            System.out.println( "thread(" + hashCode() + "): connected..." );            garage._populate( new Integer( 10 ) );            garage.printAll();        } catch (Exception e) {            e.printStackTrace();        }     } }public class Client extends Object {            public static void main( String[] args ) throws Exception {        try {            RemoteDatabase db = new RemoteDatabase();            db.open( "localhost", 3333 );                        //            LocalDatabase db = new LocalDatabase();            //            db.open ("/tmp/db", LogWriter.DEBUG3);                        db.reloadClasses();                        RemoteDatabase db2 = new RemoteDatabase();            //            db2.open ("localhost", 3333);                        Garage garage = (Garage)db.objectForName( "MG" );            if (garage == null) {                garage = (Garage)db.createObject( GarageImpl.class.getName(), Database.Public, "MG" );            }                         Thread t1 = new AccessThread( db );            t1.setPriority( Thread.currentThread().getPriority() );            t1.setName( "t1" );            t1.start();                        System.out.println( "wait..." );            Thread.sleep( 3000 );            System.out.println( "go on..." );                        Thread t2 = new AccessThread( db );            t2.setPriority( Thread.currentThread().getPriority() );            t2.setName( "t2" );            t2.start();                        Thread.sleep( 1000 );            while (t1.isAlive() || t2.isAlive()) {                System.out.println( "wait for threads..." );                Thread.sleep( 1000 );            }                         // db.deleteObject (garage);                        db.close();            db2.close();            System.out.println( "deconnected..." );        } catch (Throwable e) {            e.printStackTrace( System.out );            System.exit( 1 );        }     } }

⌨️ 快捷键说明

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