亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? log.java

?? Java寫的含有一個jdbc驅動的小型數據庫數據庫引擎
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Log.java
 *
 * Copyright (c) 2001, The HSQL Development Group
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 *
 * Neither the name of the HSQL Development Group nor the names of its
 * contributors may be used to endorse or promote products derived from this
 * software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This package is based on HypersonicSQL, originally developed by Thomas Mueller.
 *
 */
package org.hsqldb;

import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;

/**
 * <P>This class is responsible for most file handling.
 * A HSQL database consists of a .properties file, a
 * .script file (contains a SQL script), a
 * .data file (contains data of cached tables) and a
 * .backup file (contains the compressed .data file)
 *
 * <P>This is an example of the .properties file. The version and the
 * modified properties are automatically created by the database and
 * should not be changed manually:
 * <pre>
 * modified=no
 * version=1.3
 * </pre>
 * The following lines are optional, this means they are not
 * created automatically by the database, but they are interpreted
 * if they exist in the .script file. They have to be created
 * manually if required. If they don't exist the default is used.
 * This are the defaults of the database 'test':
 * <pre>
 * script=test.script
 * data=test.data
 * backup=test.backup
 * readonly=false
 * </pre>
 */
class Log implements Runnable {
    private final static int COPY_BLOCK_SIZE =
	1 << 16;			     // block size for copying data
    private FileInputStream  fProperties;    // kept open until closed
    private Properties       pProperties;
    private String	     sName;
    private Database	     dDatabase;
    private Channel	     cSystem;
    private Writer	     wScript;
    private String	     sFileProperties;
    private String	     sFileScript;
    private String	     sFileCache;
    private String	     sFileBackup;
    private boolean	     bRestoring;
    private boolean	     bReadOnly;
    private int		     iLogSize =
	200;				     // default: .script file is max 200 MB big
    private int		     iLogCount;
    private Thread	     tRunner;
    private volatile boolean bNeedFlush;
    private volatile boolean bWriteDelay;
    private int		     mLastId;
    Cache		     cCache;

    /**
     * Constructor declaration
     *
     *
     * @param db
     * @param system
     * @param name
     */
    Log(Database db, Channel system, String name) throws SQLException {
	dDatabase = db;
	cSystem = system;
	sName = name;
	sFileProperties = sName + ".properties";
	pProperties = new Properties();
	tRunner = new Thread(this);

	tRunner.start();
    }

    /**
     * Method declaration
     *
     */
    public void run() {
	while (tRunner != null) {
	    try {
		tRunner.sleep(1000);

		if (bNeedFlush) {
		    wScript.flush();

		    bNeedFlush = false;
		}

		// todo: try to do Cache.cleanUp() here, too
	    } catch (Exception e) {

		// ignore exceptions; may be InterruptedException or IOException
	    }
	}
    }

    /**
     * Method declaration
     *
     *
     * @param delay
     */
    void setWriteDelay(boolean delay) {
	bWriteDelay = delay;
    }

    /**
     * Method declaration
     *
     *
     * @return
     *
     * @throws SQLException
     */
    boolean open() throws SQLException {
	if (Trace.TRACE) {
	    Trace.trace();
	}

	if (!(new File(sFileProperties)).exists()) {
	    create();
	    open();

	    // this is a new database
	    return true;
	}

	// todo: some parts are not necessary for ready-only access
	loadProperties();

	sFileScript = pProperties.getProperty("script", sName + ".script");
	sFileCache = pProperties.getProperty("data", sName + ".data");
	sFileBackup = pProperties.getProperty("backup", sName + ".backup");

	String  version = pProperties.getProperty("version", "1.0");
// fredt@users.sourceforge.net begin changes for 1.61
// enable opening older version databases, disable opening newer version
// the first three characters are compared so that version 1.60 can open
// version 1.62 databases but not version 1.72 databases

//	boolean check = version.equals(jdbcDriver.VERSION);
	boolean check = version.substring(0,3).compareTo(jdbcDriver.VERSION) <= 0;
   // save as the current version
   pProperties.setProperty("version", jdbcDriver.VERSION);
// fredt@users.sourceforge.net end changes for 1.61

	Trace.check(check, Trace.WRONG_DATABASE_FILE_VERSION);

	if (pProperties.getProperty("readonly", "false").equals("true")) {
	    bReadOnly = true;

	    dDatabase.setReadOnly();

	    cCache = new Cache(sFileCache);

	    cCache.open(true);
	    runScript();

	    return false;
	}

	boolean needbackup = false;
	String  state = pProperties.getProperty("modified", "no");

	if (state.equals("yes-new-files")) {
	    renameNewToCurrent(sFileScript);
	    renameNewToCurrent(sFileBackup);
	} else if (state.equals("yes")) {
	    if (isAlreadyOpen()) {
		throw Trace.error(Trace.DATABASE_ALREADY_IN_USE);
	    }

	    // recovering after a crash (or forgot to close correctly)
	    restoreBackup();

	    needbackup = true;
	}

	pProperties.put("modified", "yes");
	saveProperties();

	cCache = new Cache(sFileCache);

	cCache.open(false);
	runScript();

	if (needbackup) {
	    close(false);
	    pProperties.put("modified", "yes");
	    saveProperties();
	    cCache.open(false);
	}

	openScript();

	// this is a existing database
	return false;
    }

    /**
     * Method declaration
     *
     */
    void stop() {
	tRunner = null;
    }

    /**
     * Method declaration
     *
     *
     * @param compact
     *
     * @throws SQLException
     */
    void close(boolean compact) throws SQLException {
	if (Trace.TRACE) {
	    Trace.trace();
	}

	if (bReadOnly) {
	    return;
	}

	// no more scripting
	closeScript();

	// create '.script.new' (for this the cache may be still required)
	writeScript(compact);

	// flush the cache (important: after writing the script)
	cCache.flush();

	// create '.backup.new' using the '.data'
	backup();

	// we have the new files
	pProperties.put("modified", "yes-new-files");
	saveProperties();

	// old files can be removed and new files renamed
	renameNewToCurrent(sFileScript);
	renameNewToCurrent(sFileBackup);

	// now its done completely
	pProperties.put("modified", "no");
	saveProperties();
	closeProperties();

	if (compact) {

	    // stop the runner thread of this process (just for security)
	    stop();

	    // delete the .data so then a new file is created
	    (new File(sFileCache)).delete();
	    (new File(sFileBackup)).delete();

	    // all files are closed now; simply open & close this database
	    Database db = new Database(sName);

	    db.getLog().close(false);
	}
    }

    /**
     * Method declaration
     *
     *
     * @throws SQLException
     */
    void checkpoint() throws SQLException {
	close(false);
	pProperties.put("modified", "yes");
	saveProperties();
	cCache.open(false);
	openScript();
    }

    /**
     * Method declaration
     *
     *
     * @param mb
     */
    void setLogSize(int mb) {
	iLogSize = mb;
    }

    /**
     * Method declaration
     *
     *
     * @param c
     * @param s
     *
     * @throws SQLException
     */
    void write(Channel c, String s) throws SQLException {
	if (bRestoring || s == null || s.equals("")) {
	    return;
	}

	if (!bReadOnly) {
		int id = 0;

		if (c != null) {
		    id = c.getId();
		}

		if (id != mLastId) {
		    s = "/*C" + id + "*/" + s;
		    mLastId = id;
		}

		try {
		    writeLine(wScript, s);

		    if (bWriteDelay) {
			bNeedFlush = true;
		    } else {
			wScript.flush();
		    }
		} catch (IOException e) {
		    Trace.error(Trace.FILE_IO_ERROR, sFileScript);
		}

		if (iLogSize > 0 && iLogCount++ > 100) {
		    iLogCount = 0;

		    if ((new File(sFileScript)).length() > iLogSize * 1024 * 1024) {
				checkpoint();
		    }
		}
	}

    }

    /**
     * Method declaration
     *
     *
     * @throws SQLException
     */
    void shutdown() throws SQLException {
	tRunner = null;

	cCache.shutdown();
	closeScript();
	closeProperties();
    }

    /**
     * Method declaration
     *
     *
     * @param db
     * @param file
     * @param full
     * @param channel
     *
     * @throws SQLException
     */
    static void scriptToFile(Database db, String file, boolean full,
			     Channel channel) throws SQLException {
	if ((new File(file)).exists()) {

	    // there must be no such file; overwriting not allowed for security
	    throw Trace.error(Trace.FILE_IO_ERROR, file);
	}

	try {
	    long   time = System.currentTimeMillis();

	    // only ddl commands; needs not so much memory
	    Result r;

	    if (full) {

		// no drop, no insert, and no positions for cached tables
		r = db.getScript(false, false, false, channel);
	    } else {

		// no drop, no insert, but positions for cached tables
		r = db.getScript(false, false, true, channel);
	    }

	    Record     n = r.rRoot;
	    FileWriter w = new FileWriter(file);

	    while (n != null) {
		writeLine(w, (String) n.data[0]);

		n = n.next;
	    }

	    // inserts are done separetely to save memory
	    Vector tables = db.getTables();

	    for (int i = 0; i < tables.size(); i++) {
		Table t = (Table) tables.elementAt(i);

		// cached tables have the index roots set in the ddl script
		if (full ||!t.isCached()) {
		    Index primary = t.getPrimaryIndex();
		    Node  x = primary.first();

		    while (x != null) {
			writeLine(w, t.getInsertStatement(x.getData()));

			x = primary.next(x);
		    }
		}
	    }

	    w.close();

	    time = System.currentTimeMillis() - time;

	    if (Trace.TRACE) {
		Trace.trace(time);
	    }
	} catch (IOException e) {
	    Trace.error(Trace.FILE_IO_ERROR, file + " " + e);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美中文一区| 亚洲国产视频在线| 在线成人av网站| 成人蜜臀av电影| 久久国产麻豆精品| 亚洲成人免费av| 亚洲成人www| 福利一区福利二区| 国产伦精品一区二区三区免费 | 亚洲精品中文在线影院| 国产精品色婷婷| 国产欧美日韩激情| 国产精品欧美一区喷水| 蜜桃一区二区三区在线观看| 免费一级欧美片在线观看| 日韩av不卡一区二区| 精东粉嫩av免费一区二区三区| 精品在线观看免费| 欧美日精品一区视频| 欧美老年两性高潮| 亚洲同性同志一二三专区| 亚洲欧美日韩国产另类专区| 一区二区三区不卡视频| 天堂久久一区二区三区| 久久99最新地址| 91精品欧美久久久久久动漫| 日韩精品综合一本久道在线视频| 精品美女被调教视频大全网站| 26uuu亚洲| 中文字幕一区二区三区不卡在线| 亚洲人成网站影音先锋播放| 国产成人在线视频播放| 在线观看亚洲专区| 欧美va在线播放| 日本视频一区二区| 欧美精品v日韩精品v韩国精品v| 亚洲蜜桃精久久久久久久| jizzjizzjizz欧美| 欧美视频一二三区| 337p日本欧洲亚洲大胆精品| 免费久久99精品国产| 欧美卡1卡2卡| 日韩一区欧美二区| 337p亚洲精品色噜噜| 水野朝阳av一区二区三区| 欧美三级电影在线看| 三级不卡在线观看| 欧美一区二区性放荡片| 国产精品免费久久| eeuss鲁片一区二区三区在线看| 国产精品拍天天在线| 97精品久久久久中文字幕 | 韩国av一区二区三区| 色先锋久久av资源部| 欧美r级在线观看| 精品无人区卡一卡二卡三乱码免费卡| 精品日韩在线观看| 国产成人免费xxxxxxxx| 国产精品三级电影| 91年精品国产| 国产欧美日韩激情| 一本色道久久综合精品竹菊 | 精品国产欧美一区二区| 亚洲国产一区二区在线播放| 91超碰这里只有精品国产| 久久精品国产精品亚洲红杏| 国产午夜一区二区三区| 免费看欧美女人艹b| 26uuu色噜噜精品一区二区| 成人av先锋影音| 欧美变态tickling挠脚心| 国产福利一区在线| 亚洲一区在线视频观看| 97精品国产露脸对白| 亚洲国产成人91porn| 久久嫩草精品久久久精品| 蜜桃久久精品一区二区| 日本一区二区综合亚洲| 欧美性猛交xxxxxx富婆| 99久久精品国产一区二区三区 | 欧美日韩国产大片| 亚洲同性同志一二三专区| 91精品久久久久久久久99蜜臂| 国产一区二区免费在线| 亚洲欧美一区二区久久| 日韩免费成人网| 色婷婷精品大在线视频| 狠狠狠色丁香婷婷综合久久五月| 亚洲视频图片小说| 26uuu色噜噜精品一区二区| 99久久精品国产麻豆演员表| 蜜桃精品视频在线观看| 亚洲婷婷综合色高清在线| 日韩精品一区二区三区四区 | 国产精品久久久一区麻豆最新章节| 久久精品噜噜噜成人88aⅴ| 1区2区3区精品视频| 精品久久人人做人人爽| 欧美日韩中文字幕一区二区| 国产成人精品影视| 琪琪久久久久日韩精品| 亚洲一区免费视频| 日韩伦理av电影| 国产日韩三级在线| 日韩精品专区在线影院观看| 欧美日韩一区久久| 色综合久久久网| 成人免费观看av| 国产精品自拍三区| 国产精品乱码人人做人人爱| 精品国产一区二区三区不卡| 欧美日韩成人综合天天影院| 色屁屁一区二区| 91精品国产综合久久精品麻豆| 一本色道久久加勒比精品| 成人a区在线观看| 粉嫩一区二区三区在线看| 狠狠色伊人亚洲综合成人| 人人超碰91尤物精品国产| 亚洲国产中文字幕| 性做久久久久久免费观看| 一区二区三区在线观看欧美| 亚洲人被黑人高潮完整版| 国产精品高潮久久久久无| 国产农村妇女精品| 国产欧美精品在线观看| 欧美国产日韩a欧美在线观看| 99久久伊人精品| 国产69精品久久久久毛片| 粉嫩一区二区三区性色av| 国产精品一区二区果冻传媒| 国产成人8x视频一区二区| 成人午夜精品一区二区三区| 国产1区2区3区精品美女| 国产成人精品www牛牛影视| 国产suv精品一区二区883| 粉嫩13p一区二区三区| 成人国产精品免费网站| 91麻豆国产在线观看| 欧洲一区在线电影| 在线播放亚洲一区| 欧美精品一区二区三区在线播放| 久久伊人蜜桃av一区二区| 久久精品亚洲乱码伦伦中文| 国产精品久久久久9999吃药| 一区二区三区波多野结衣在线观看| 性欧美大战久久久久久久久| 欧美aaaaa成人免费观看视频| 麻豆国产精品视频| 成人视屏免费看| 91久久免费观看| 成人av动漫在线| 91成人国产精品| 日韩欧美高清一区| 国产精品久久久久影视| 亚洲国产综合人成综合网站| 久久99国产精品免费网站| av日韩在线网站| 欧美日韩一级二级| www国产精品av| 一区二区三区中文在线观看| 免费看黄色91| 91天堂素人约啪| 欧美不卡视频一区| 亚洲精品美腿丝袜| 激情综合一区二区三区| 91亚洲精华国产精华精华液| 91精品国产高清一区二区三区 | 国产欧美在线观看一区| 亚洲国产另类精品专区| 国产精品小仙女| 欧美人与z0zoxxxx视频| 国产精品美女久久久久久久 | 欧美午夜精品理论片a级按摩| 精品国产乱码久久| 亚洲成人免费看| 不卡一二三区首页| 欧美成人综合网站| 亚洲精品自拍动漫在线| 国产suv一区二区三区88区| 欧美情侣在线播放| 亚洲免费av网站| 成人深夜视频在线观看| 欧美sm美女调教| 亚州成人在线电影| 91美女精品福利| 日本一区二区三区四区| 麻豆传媒一区二区三区| 精品视频在线视频| 国产精品短视频| 国产一区二区三区四区五区入口 | 中文字幕制服丝袜一区二区三区| 麻豆精品国产传媒mv男同| 欧美中文字幕一二三区视频| 国产精品少妇自拍| 国产精品资源网站| 精品国精品国产| 激情小说亚洲一区| 日韩三级高清在线| 免费成人在线播放|