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

📄 myapp.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
import org.ozoneDB.*;public class MyApp {        private static ExternalDatabase	db;    public static void main( String[] args ) throws Exception {        if (args.length == 0) {            System.out.println( "usage: ojvm MyApp create|delete|print" );            System.exit( 1 );        }                // create and open a new database connection        db = ExternalDatabase.openDatabase( "ozonedb:remote://localhost:3333" );        System.out.println( "Connected ..." );                db.reloadClasses();                if (args[0].equals( "create" )) {            createCar();        } else if (args[0].equals( "delete" )) {            deleteCar();        } else {            printCar();        }                db.close();    }    public static void createCar() throws Exception {        // create a new Car object with the name "my_first_car"        // the return value is Car_proxy, which implements the Car-interface        Car car = (Car)(db.createObject( CarImpl.class.getName(), 0,                "my_first_car" ));                car.setName( "gottfried" );        car.setYearOfConst( 1957 );    }    public static void printCar() throws Exception {        Car car = (Car)(db.objectForName( "my_first_car" ));        if (car != null) {            System.out.println( "The car " + car.name() + " is "                     + car.age() + " years old." );        } else {            System.out.println( "Object my_first_car not found." );        }    }        public static void deleteCar() throws Exception {        Car car = (Car)(db.objectForName( "my_first_car" ));        if (car != null) {            db.deleteObject( car );        } else {            System.out.println( "Object my_first_car not found." );        }    }}

⌨️ 快捷键说明

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