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

📄 testlogc.java

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 JAVA
字号:
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1997-2002 *	Sleepycat Software.  All rights reserved. * * $Id: TestLogc.java,v 1.7 2002/08/16 19:35:55 dda Exp $ *//* * A basic regression test for the Logc class. */package com.sleepycat.test;import com.sleepycat.db.*;import java.io.FileNotFoundException;public class TestLogc{    public static void main(String[] args)    {        try {            DbEnv env = new DbEnv(0);            env.open(".", Db.DB_CREATE | Db.DB_INIT_LOG | Db.DB_INIT_MPOOL, 0);            // Do some database activity to get something into the log.            Db db1 = new Db(env, 0);            db1.open(null, "first.db", null, Db.DB_BTREE, Db.DB_CREATE, 0);            db1.put(null, new Dbt("a".getBytes()), new Dbt("b".getBytes()), 0);            db1.put(null, new Dbt("c".getBytes()), new Dbt("d".getBytes()), 0);            db1.close(0);            Db db2 = new Db(env, 0);            db2.open(null, "second.db", null, Db.DB_BTREE, Db.DB_CREATE, 0644);            db2.put(null, new Dbt("w".getBytes()), new Dbt("x".getBytes()), 0);            db2.put(null, new Dbt("y".getBytes()), new Dbt("z".getBytes()), 0);            db2.close(0);            // Now get a log cursor and walk through.            DbLogc logc = env.log_cursor(0);            int ret = 0;            DbLsn lsn = new DbLsn();            Dbt dbt = new Dbt();            int flags = Db.DB_FIRST;            int count = 0;            while ((ret = logc.get(lsn, dbt, flags)) == 0) {                // We ignore the contents of the log record,                // it's not portable.  Even the exact count                // is may change when the underlying implementation                // changes, we'll just make sure at the end we saw                // 'enough'.                //                //     System.out.println("logc.get: " + count);                //     System.out.println(showDbt(dbt));                //                count++;                flags = Db.DB_NEXT;            }            if (ret != Db.DB_NOTFOUND) {                System.err.println("*** FAIL: logc.get returned: " +                                   DbEnv.strerror(ret));            }            logc.close(0);            // There has to be at *least* four log records,            // since we did four separate database operations.            //            if (count < 4)                System.out.println("*** FAIL: not enough log records");            System.out.println("TestLogc done.");        }        catch (DbException dbe) {            System.err.println("*** FAIL: Db Exception: " + dbe);        }        catch (FileNotFoundException fnfe) {            System.err.println("*** FAIL: FileNotFoundException: " + fnfe);        }    }    public static String showDbt(Dbt dbt)    {        StringBuffer sb = new StringBuffer();        int size = dbt.get_size();        byte[] data = dbt.get_data();        int i;        for (i=0; i<size && i<10; i++) {            sb.append(Byte.toString(data[i]));            sb.append(' ');        }        if (i<size)            sb.append("...");        return "size: " + size + " data: " + sb.toString();    }}

⌨️ 快捷键说明

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