📄 client.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.23 2000/10/28 16:55:19 daniela Exp $package org.ozoneDB.test;import java.io.*;import java.util.*;import java.lang.reflect.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.*;/** */class LocalThread extends Thread { LocalDatabase db; String name; int num; /** */ public LocalThread( LocalDatabase _db, String _name, int _num ) { db = _db; name = _name; num = _num; } /** */ public void run() { try { RemoteDatabase db = new RemoteDatabase(); db.open( "localhost", 3333 ); db.reloadClasses(); System.out.println( "thread(" + hashCode() + "): connected..." ); Garage garage = (Garage)db.objectForName( "MG" ); if (garage == null) { garage = (Garage)db.createObject( GarageImpl.class.getName(), Database.Public, "MG" ); } garage.printAll(); } catch (Exception e) { e.printStackTrace(); } } }/** */public class Client extends Object { public static void dummy( long _long ) { } public static void main( String[] args ) throws Exception { RemoteDatabase db = new RemoteDatabase(); db.open( "localhost", 3333 ); db.reloadClasses(); System.out.println( "connected..." ); long start = System.currentTimeMillis(); // ExternalTransaction tx = db.newTransaction(); // tx.begin(); int num = Integer.parseInt( args[0] ); for (int i = 0; i < num; i++) { Auto auto = (Auto)db.createObject( AutoImpl.class.getName(), Database.Public, null ); auto.setName( String.valueOf( i ) ); // db.deleteObject (auto); } // tx.commit(); System.out.println( System.currentTimeMillis() - start ); start = System.currentTimeMillis(); Garage garage = (Garage)db.createObject( GarageImpl.class.getName(), Database.Public, null ); garage._populate( new Integer( num ) ); System.out.println( System.currentTimeMillis() - start ); db.close(); // try { // RemoteDatabase db = new RemoteDatabase(); // db.open ("localhost", 3333, "", ""); // // db.reloadClasses(); // System.out.println ("connected..."); // // int num = Integer.parseInt (args[0]); // // Garage garage = (Garage)db.objectForName ("MG"); // if (garage == null) // garage = (Garage)db.createObject (GarageImpl.class.getName(), Database.Public, "MG"); // // garage._populate (new Integer(num)); // // int[] a1 = new int[100000]; // Integer[] a2 = new Integer[1000]; // int[] r = garage._setAll (new AutoImpl(), a1, a2); // // String name = "Primitive Test"; // garage._newAuto (name); // System.out.println (name); // Auto auto = garage.autoForName ("Primitive Test"); // int oldAge = auto.setAge (10); // System.out.println ("old age: " + oldAge); // Integer newAge = auto.age(); // System.out.println ("new age: " + newAge.intValue()); // // System.out.println (r.toString()); // garage.printAll(); // // garage.done(); // // System.out.println (garage.toString()); // db.deleteObject (garage); // // // auto = (Auto)db.createObject (AutoImpl.class.getName(), Database.Public, "auto"); // auto = (Auto)db.objectForName ("auto"); // Auto auto2 = (Auto)auto.doSomthing(auto); // auto.print(); // auto.setAge (new Integer(3)); // auto.print(); // db.deleteObject (auto); // // db.close(); // System.out.println ("deconnected..."); // } // catch (Throwable e) { // e.printStackTrace (System.out); // } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -