当前位置: 首页>>代码示例>>Java>>正文


Java DeleteDbFiles.execute方法代码示例

本文整理汇总了Java中org.h2.tools.DeleteDbFiles.execute方法的典型用法代码示例。如果您正苦于以下问题:Java DeleteDbFiles.execute方法的具体用法?Java DeleteDbFiles.execute怎么用?Java DeleteDbFiles.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.tools.DeleteDbFiles的用法示例。


在下文中一共展示了DeleteDbFiles.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSplitDatabaseInZip

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testSplitDatabaseInZip() throws SQLException {
    String dir = getBaseDir() + "/fs";
    FileUtils.deleteRecursive(dir, false);
    Connection conn;
    Statement stat;
    conn = getConnection("jdbc:h2:split:18:"+dir+"/test");
    stat = conn.createStatement();
    stat.execute(
            "create table test(id int primary key, name varchar) " +
            "as select x, space(10000) from system_range(1, 100)");
    // stat.execute("shutdown defrag");
    conn.close();
    Backup.execute(dir + "/test.zip", dir, "", true);
    DeleteDbFiles.execute("split:" + dir, "test", true);
    conn = getConnection(
            "jdbc:h2:split:zip:"+dir+"/test.zip!/test");
    conn.createStatement().execute("select * from test where id=1");
    conn.close();
    FileUtils.deleteRecursive(dir, false);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:21,代码来源:TestFileSystem.java

示例2: setup

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
/** Prepares Db and data source, which must be added to Camel registry. */
@BeforeClass
public static void setup() throws Exception {
    DeleteDbFiles.execute("~", "jbpm-db-test", true);

    h2Server = Server.createTcpServer(new String[0]);
    h2Server.start();

    setupDb();

    DataSource ds = setupDataSource();

    SimpleRegistry simpleRegistry = new SimpleRegistry();
    simpleRegistry.put("myDs", ds);

    handler = new CamelHandler(new SQLURIMapper(), new RequestPayloadMapper("payload"), new ResponsePayloadMapper("queryResult"), new DefaultCamelContext(simpleRegistry));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:18,代码来源:CamelSqlTest.java

示例3: main

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
/**
 * Run just this test.
 *
 * @param args ignored
 */
public static void main(String... args) throws Exception {
    DeleteDbFiles.execute("data", null, true);
    Class.forName("org.h2.Driver");
    Connection conn;
    conn = DriverManager.getConnection("jdbc:h2:data/test");
    Statement stat = conn.createStatement();
    stat.execute("create table test(id int primary key, name varchar)");
    stat.execute("insert into test values(1, 'Hello')");
    stat.execute("insert into test values(2, 'World')");
    stat.execute("create linked table test_link" +
            "('', 'jdbc:h2:data/test', '', '', 'TEST')");
    stat.execute("set trace_level_system_out 2");
    // the query sent to the linked database is
    // SELECT * FROM PUBLIC.TEST T WHERE ID>=? AND ID<=? {1: 1, 2: 1};
    // it should also include AND NAME='Hello'
    stat.execute("select * from test_link " +
            "where id = 1 and name = 'Hello'");
    conn.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:TestLinkedTableFullCondition.java

示例4: main

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
/**
 * Called when ran from command line.
 *
 * @param args ignored
 */
public static void main(String... args) throws Exception {
    // delete the database named 'test' in the user home directory
    DeleteDbFiles.execute("~", "test", true);

    Class.forName("org.h2.Driver");
    Connection conn = DriverManager.getConnection("jdbc:h2:~/test");
    Statement stat = conn.createStatement();

    // this line would initialize the database
    // from the SQL script file 'init.sql'
    // stat.execute("runscript from 'init.sql'");

    stat.execute("create table test(id int primary key, name varchar(255))");
    stat.execute("insert into test values(1, 'Hello')");
    ResultSet rs;
    rs = stat.executeQuery("select * from test");
    while (rs.next()) {
        System.out.println(rs.getString("name"));
    }
    stat.close();
    conn.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:HelloWorld.java

示例5: testRecoverFulltext

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testRecoverFulltext() throws Exception {
    DeleteDbFiles.execute(getBaseDir(), "recovery", true);
    Connection conn = getConnection("recovery");
    Statement stat = conn.createStatement();
    stat.execute("CREATE ALIAS IF NOT EXISTS FTL_INIT " +
            "FOR \"org.h2.fulltext.FullTextLucene.init\"");
    stat.execute("CALL FTL_INIT()");
    stat.execute("create table test(id int primary key, name varchar) as " +
            "select 1, 'Hello'");
    stat.execute("CALL FTL_CREATE_INDEX('PUBLIC', 'TEST', 'NAME')");
    conn.close();
    Recover.main("-dir", getBaseDir(), "-db", "recovery");
    DeleteDbFiles.execute(getBaseDir(), "recovery", true);
    conn = getConnection(
            "recovery;init=runscript from '" +
            getBaseDir() + "/recovery.h2.sql'");
    conn.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:19,代码来源:TestRecovery.java

示例6: testDeleteFiles

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testDeleteFiles() throws SQLException {
    deleteDb("testDeleteFiles");
    Connection conn = getConnection("testDeleteFiles");
    Statement stat = conn.createStatement();
    stat.execute("create table test(c clob) as select space(10000) from dual");
    conn.close();
    // the name starts with the same string, but does not match it
    DeleteDbFiles.execute(getBaseDir(), "testDelete", true);
    conn = getConnection("testDeleteFiles");
    stat = conn.createStatement();
    ResultSet rs;
    rs = stat.executeQuery("select * from test");
    rs.next();
    rs.getString(1);
    conn.close();
    deleteDb("testDeleteFiles");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:TestTools.java

示例7: main

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
    // delete the database named 'test' in the user home directory
    DeleteDbFiles.execute("~", "test", true);

    Class.forName("org.h2.Driver");
    Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "admin", "admin");
    Statement stat = conn.createStatement();

    // this line would initialize the database
    // from the SQL script file 'init.sql'
    // stat.execute("runscript from 'init.sql'");

    stat.execute("create table test(id int primary key, name varchar(255))");
    stat.execute("insert into test values(1, 'Hello')");
    ResultSet rs;
    rs = stat.executeQuery("select * from test");
    while (rs.next()) {
        System.out.println(rs.getString("name"));
    }
    stat.close();
    conn.close();
}
 
开发者ID:nuclearthinking,项目名称:rpg,代码行数:23,代码来源:InitializeDatabase.java

示例8: main

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
/**
 * This method is called when executing this sample application from the
 * command line.
 *
 * @param args the command line parameters
 */
public static void main(String... args) throws Exception {
    DeleteDbFiles.execute("./data", "test", true);
    Class.forName("org.h2.Driver");
    Connection conn = DriverManager.getConnection("jdbc:h2:./data/test", "sa", "");
    Statement stat = conn.createStatement();
    stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
    stat.execute("INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');");
    stat.close();
    conn.close();
    System.out.println("Compacting...");
    compact("./data", "test", "sa", "");
    System.out.println("Done.");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:Compact.java

示例9: testCorrupt

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testCorrupt() throws Exception {
    if (config.mvStore) {
        // not needed for MV_STORE=TRUE
        return;
    }
    DeleteDbFiles.execute(getBaseDir(), "recovery", true);
    Connection conn = getConnection("recovery");
    Statement stat = conn.createStatement();
    stat.execute("create table test(id int, name varchar) as " +
            "select 1, 'Hello World1'");
    conn.close();
    FileChannel f = FileUtils.open(getBaseDir() + "/recovery.h2.db", "rw");
    byte[] buff = new byte[Constants.DEFAULT_PAGE_SIZE];
    while (f.position() < f.size()) {
        FileUtils.readFully(f, ByteBuffer.wrap(buff));
        if (new String(buff).contains("Hello World1")) {
            buff[buff.length - 1]++;
            f.position(f.position() - buff.length);
            f.write(ByteBuffer.wrap(buff));
        }
    }
    f.close();
    Recover.main("-dir", getBaseDir(), "-db", "recovery");
    String script = IOUtils.readStringAndClose(
            new InputStreamReader(
            FileUtils.newInputStream(getBaseDir() + "/recovery.h2.sql")), -1);
    assertContains(script, "checksum mismatch");
    assertContains(script, "dump:");
    assertContains(script, "Hello World2");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:TestRecovery.java

示例10: main

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
/**
 * This method is called when executing this sample application from the
 * command line.
 *
 * @param args the command line parameters
 */
public static void main(String... args) throws Exception {
    Class.forName("org.h2.Driver");
    DeleteDbFiles.execute("~", "test", true);
    String url = "jdbc:h2:~/test";
    initialInsert(url, 200000);
    for (int i = 0; i < 3; i++) {
        createAsSelect(url, true);
        createAsSelect(url, false);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:DirectInsert.java

示例11: testCompressedAndUncompressed

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testCompressedAndUncompressed() throws SQLException {
    DeleteDbFiles.execute(getBaseDir(), "recovery", true);
    DeleteDbFiles.execute(getBaseDir(), "recovery2", true);
    org.h2.Driver.load();
    Connection conn = getConnection("recovery");
    Statement stat = conn.createStatement();
    stat.execute("create table test(id int primary key, data clob)");
    stat.execute("insert into test values(1, space(10000))");
    stat.execute("set compress_lob lzf");
    stat.execute("insert into test values(2, space(10000))");
    conn.close();
    Recover rec = new Recover();
    rec.runTool("-dir", getBaseDir(), "-db", "recovery");
    Connection conn2 = getConnection("recovery2");
    Statement stat2 = conn2.createStatement();
    String name = "recovery.h2.sql";
    stat2.execute("runscript from '" + getBaseDir() + "/" + name + "'");
    stat2.execute("select * from test");
    conn2.close();

    conn = getConnection("recovery");
    stat = conn.createStatement();
    conn2 = getConnection("recovery2");
    stat2 = conn2.createStatement();

    assertEqualDatabases(stat, stat2);
    conn.close();
    conn2.close();
    DeleteDbFiles.execute(getBaseDir(), "recovery", true);
    DeleteDbFiles.execute(getBaseDir(), "recovery2", true);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:32,代码来源:TestRecovery.java

示例12: compact

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
/**
 * Utility method to compact a database.
 *
 * @param dir the directory
 * @param dbName the database name
 * @param user the user name
 * @param password the password
 */
public static void compact(String dir, String dbName,
        String user, String password) throws SQLException {
    String url = "jdbc:h2:" + dir + "/" + dbName;
    String file = "data/test.sql";
    Script.process(url, user, password, file, "", "");
    DeleteDbFiles.execute(dir, dbName, true);
    RunScript.execute(url, user, password, file, null, false);
    FileUtils.delete(file);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:Compact.java

示例13: testImplicitRelativePath

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testImplicitRelativePath() throws Exception {
    if (SysProperties.IMPLICIT_RELATIVE_PATH) {
        return;
    }
    assertThrows(ErrorCode.URL_RELATIVE_TO_CWD, this).
        getConnection("jdbc:h2:test");
    assertThrows(ErrorCode.URL_RELATIVE_TO_CWD, this).
        getConnection("jdbc:h2:data/test");

    getConnection("jdbc:h2:./testDatabase").close();
    DeleteDbFiles.execute(".", "testDatabase", true);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:13,代码来源:TestConnectionInfo.java

示例14: testChangeFileEncryption

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void testChangeFileEncryption(boolean split) throws SQLException {
    org.h2.Driver.load();
    final String dir = (split ? "split:19:" : "") + getBaseDir();
    String url = "jdbc:h2:" + dir + "/testChangeFileEncryption;CIPHER=AES";
    DeleteDbFiles.execute(dir, "testChangeFileEncryption", true);
    Connection conn = getConnection(url, "sa", "abc 123");
    Statement stat = conn.createStatement();
    stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, DATA CLOB) "
            + "AS SELECT X, SPACE(3000) FROM SYSTEM_RANGE(1, 300)");
    conn.close();
    String[] args = { "-dir", dir, "-db", "testChangeFileEncryption",
            "-cipher", "AES", "-decrypt", "abc", "-quiet" };
    ChangeFileEncryption.main(args);
    args = new String[] { "-dir", dir, "-db", "testChangeFileEncryption",
            "-cipher", "AES", "-encrypt", "def", "-quiet" };
    ChangeFileEncryption.main(args);
    conn = getConnection(url, "sa", "def 123");
    stat = conn.createStatement();
    stat.execute("SELECT * FROM TEST");
    new AssertThrows(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1) {
        @Override
        public void test() throws SQLException {
            ChangeFileEncryption.main(new String[] { "-dir", dir, "-db",
                    "testChangeFileEncryption", "-cipher", "AES",
                    "-decrypt", "def", "-quiet" });
        }
    };
    conn.close();
    args = new String[] { "-dir", dir, "-db", "testChangeFileEncryption",
            "-quiet" };
    DeleteDbFiles.main(args);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:33,代码来源:TestTools.java

示例15: deleteDb

import org.h2.tools.DeleteDbFiles; //导入方法依赖的package包/类
private void deleteDb() {
    String name = getDatabaseName();
    if (name.startsWith("memFS:")) {
        DeleteDbFiles.execute("memFS:/", name, true);
    } else {
        DeleteDbFiles.execute(getBaseDir() + "/dataRandomSQL", null, true);
        FileUtils.delete(getBaseDir() + "/dataRandomSQL");
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:10,代码来源:TestRandomSQL.java


注:本文中的org.h2.tools.DeleteDbFiles.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。