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

📄 install.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: Install.java,v 1.34 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.tools;import java.io.*;import java.util.*;import org.ozoneDB.*;import org.ozoneDB.core.*;public class Install extends Object {        protected static String dirName;        protected static PrintWriter log;            public static void main( String[] args ) throws Exception {        String dir = File.separator + "tmp" + File.separator + "db" + File.separator;        boolean help = false;                for (int i = 0; i < args.length; i++) {            if (args[i].startsWith( "-d" )) {                dir = args[i].substring( 2 ) + File.separator;            } else if (args[i].startsWith( "-h" )) {                help = true;            } else {                System.out.println( "illegal option: " + args[i] );                help = true;            }         }                 if (args.length == 0 || help) {            System.out.println( "usage: ozoneInst -d<dir> [-D<property>=<value>]*" );            System.out.println( "   -d<directory>         database directory" );            // System.out.println ("   -id<database id>      id-number of the database");            System.out.println( "   -h                    shows this help" );            System.out.println( "" );                        System.out.println( "where properties include:" );            Setup defaults = new Setup( null );            defaults.fillWithOzoneDefaults();            for (Enumeration e = defaults.propertyNames(); e.hasMoreElements();) {                System.out.println( "    " + (String)e.nextElement() );            }             System.exit( 0 );        }                 //        try {            File file = new File( dir );            if (file.list().length > 0) {                System.out.print( "Do you want to recursively delete all files in " + dir + " ? [y/N]" );                                InputStreamReader is = new InputStreamReader( System.in );                                int c = is.read();                if (c != 'y') {                    System.exit( 0 );                }             }         } catch (Exception e) {        }                 System.out.println( "installing database in " + dir + " ..." );                Setup defaults = new Setup( null );        defaults.addProperties( System.getProperties(), "ozoneDB." );        createDB( dir, defaults, new PrintWriter( System.out, true ) );                // System.out.println ("");        System.out.println( "Edit the file " + dir + "config.properties to change settings." );        System.out.println( "Ready." );    }             public static void createDB( String _dirName, Setup _defaults, PrintWriter _log ) throws Exception {        log = _log;        dirName = _dirName + File.separator;                mkDir();        makeDataDir();        makeIdTableDir();                resetConfigFile( _defaults );        resetStateFile( _defaults );    }             /**     * Create the ozone database directory.     */    public static void mkDir() throws Exception {        //        deleteDir (dirName + Env.DATA_DIR);        //        deleteDir (dirName + Env.STATS_DIR);        deleteDir( dirName, true );                File f = new File( dirName );        if (!f.exists()) {            log.println( "making dir " + dirName + " ..." );            f.mkdir();        }     }             public static void resetStateFile( Setup config ) throws IOException {        log.println( "making " + dirName + Env.STATE_FILE + " ..." );                Setup state = new Setup( null );        long dbID = config.longProperty( Setup.DB_ID, 0 );        state.setLongProperty( Setup.XOID, dbID << 40 );        log.println( "    ID counter = " + dbID + " * 2^40" );                OutputStream out = new PrintStream( new FileOutputStream( new File( dirName, Env.STATE_FILE ) ) );        state.save( out, "Ozone Server State File.\n#Do not edit!" );        out.close();    }             public static Setup resetConfigFile( Setup _defaults ) throws IOException {        log.println( "making " + dirName + Env.CONFIG_FILE + " ..." );                Setup defaults = new Setup( null );        defaults.fillWithOzoneDefaults();        defaults.addProperties( _defaults, "ozoneDB." );                OutputStream out = new FileOutputStream( new File( dirName, Env.CONFIG_FILE ) );        defaults.save( out,                "Ozone Config File.\n" + "#\n" + "# Do not use comments. This file will be overwritten,\n"                 + "# if the config changes. See the ozone documentation\n"                 + "# for details about the properties and their values.\n" );        out.close();                defaults.print( System.out, "", "    " );        // System.out.println ("The server will use these default settings.");        return defaults;    }             /**     * Create the cluster directory.     */    public static void makeDataDir() throws IOException {        log.println( "making " + dirName + Env.DATA_DIR + " ..." );                File f = new File( dirName + Env.DATA_DIR );        if (!f.exists()) {            f.mkdir();        }     }             public static void makeIdTableDir() throws IOException {        log.println( "making " + dirName + Env.OS_DIR + " ..." );                File f = new File( dirName + Env.OS_DIR );        if (!f.exists()) {            f.mkdir();        }     }             public static void deleteDir( String path, boolean recursive ) throws IOException {        log.println( "deleting " + path + " ..." );        File f = new File( path );        String[] files = f.list();        if (files == null) {            return;        }                 for (int i = 0; i < files.length; i++) {            File file = new File( path, files[i] );            if (file.isDirectory()) {                if (recursive) {                    deleteDir( file.getPath(), recursive );                }             } else {                if (!file.delete()) {                    log.println( "Unable to delete " + file + "." );                }             }         }     } }

⌨️ 快捷键说明

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