本文整理汇总了Java中org.h2.tools.DeleteDbFiles类的典型用法代码示例。如果您正苦于以下问题:Java DeleteDbFiles类的具体用法?Java DeleteDbFiles怎么用?Java DeleteDbFiles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeleteDbFiles类属于org.h2.tools包,在下文中一共展示了DeleteDbFiles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: test
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
private static void test() throws SQLException {
DeleteDbFiles.execute("data", "test", true);
Connection conn = DriverManager.getConnection("jdbc:h2:data/test");
Statement stat = conn.createStatement();
stat.execute("create table test1(id identity, name varchar)");
stat.execute("create table test2(id identity, name varchar)");
conn.setAutoCommit(true);
// use two tables to make sure the data stored on disk is not too simple
PreparedStatement prep1 = conn.prepareStatement(
"insert into test1(name) values(space(255))");
PreparedStatement prep2 = conn.prepareStatement(
"insert into test2(name) values(space(255))");
for (int i = 0; i < 50000; i++) {
if (i % 7 != 0) {
prep1.execute();
} else {
prep2.execute();
}
}
Profiler prof = new Profiler();
prof.startCollecting();
stat.execute("DROP TABLE test1");
prof.stopCollecting();
System.out.println(prof.getTop(3));
conn.close();
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:27,代码来源:TestDropTableLarge.java
示例4: 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
示例5: test
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
private static void test() throws SQLException {
DeleteDbFiles.execute("data", "test", true);
Connection conn = DriverManager.getConnection("jdbc:h2:data/test");
Statement stat = conn.createStatement();
stat.execute("set max_operation_memory 100");
stat.execute("set max_memory_undo 100");
stat.execute("create table test(id identity, name varchar)");
conn.setAutoCommit(false);
PreparedStatement prep = conn.prepareStatement(
"insert into test(name) values(space(1024*1024))");
long time = System.currentTimeMillis();
for (int i = 0; i < 2500; i++) {
prep.execute();
long now = System.currentTimeMillis();
if (now > time + 5000) {
System.out.println(i);
time = now + 5000;
}
}
conn.rollback();
conn.close();
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:TestUndoLogLarge.java
示例6: testRecoverClob
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
private void testRecoverClob() throws Exception {
DeleteDbFiles.execute(getBaseDir(), "recovery", true);
Connection conn = getConnection("recovery");
Statement stat = conn.createStatement();
stat.execute("create table test(id int, data clob)");
stat.execute("insert into test values(1, space(100000))");
conn.close();
Recover.main("-dir", getBaseDir(), "-db", "recovery");
DeleteDbFiles.execute(getBaseDir(), "recovery", true);
conn = getConnection(
"recovery;init=runscript from '" +
getBaseDir() + "/recovery.h2.sql'");
stat = conn.createStatement();
stat.execute("select * from test");
conn.close();
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:TestRecovery.java
示例7: 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
示例8: 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
示例9: beforeTest
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
/**
* This method is called before a complete set of tests is run. It deletes
* old database files in the test directory and trace files. It also starts
* a TCP server if the test uses remote connections.
*/
public void beforeTest() throws SQLException {
Driver.load();
FileUtils.deleteRecursive(TestBase.BASE_TEST_DIR, true);
DeleteDbFiles.execute(TestBase.BASE_TEST_DIR, null, true);
FileUtils.deleteRecursive("trace.db", false);
if (networked) {
String[] args = ssl ? new String[] { "-tcpSSL", "-tcpPort", "9192" }
: new String[] { "-tcpPort", "9192" };
server = Server.createTcpServer(args);
try {
server.start();
} catch (SQLException e) {
System.out.println("FAIL: can not start server (may already be running)");
server = null;
}
}
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:TestAll.java
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: test
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
@Override
public void test() throws Exception {
if (config.networked) {
return;
}
DeleteDbFiles.execute(getBaseDir(), null, true);
org.h2.Driver.load();
testSimpleResultSet();
testTcpServerWithoutPort();
testConsole();
testJdbcDriverUtils();
testWrongServer();
testDeleteFiles();
testScriptRunscriptLob();
testServerMain();
testRemove();
testConvertTraceFile();
testManagementDb();
testChangeFileEncryption(false);
if (!config.splitFileSystem) {
testChangeFileEncryption(true);
}
testChangeFileEncryptionWithWrongPassword();
testServer();
testScriptRunscript();
testBackupRestore();
testRecover();
FileUtils.delete(getBaseDir() + "/b2.sql");
FileUtils.delete(getBaseDir() + "/b2.sql.txt");
FileUtils.delete(getBaseDir() + "/b2.zip");
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:32,代码来源:TestTools.java
示例16: testBackupRestore
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
private void testBackupRestore() throws SQLException {
org.h2.Driver.load();
String url = "jdbc:h2:" + getBaseDir() + "/testBackupRestore";
String user = "sa", password = "abc";
final String fileName = getBaseDir() + "/b2.zip";
DeleteDbFiles.main("-dir", getBaseDir(), "-db", "testBackupRestore",
"-quiet");
Connection conn = getConnection(url, user, password);
conn.createStatement().execute(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
conn.createStatement().execute("INSERT INTO TEST VALUES(1, 'Hello')");
conn.close();
Backup.main("-file", fileName, "-dir", getBaseDir(), "-db",
"testBackupRestore", "-quiet");
DeleteDbFiles.main("-dir", getBaseDir(), "-db", "testBackupRestore",
"-quiet");
Restore.main("-file", fileName, "-dir", getBaseDir(), "-db",
"testBackupRestore", "-quiet");
conn = getConnection("jdbc:h2:" + getBaseDir() + "/testBackupRestore",
"sa", "abc");
ResultSet rs = conn.createStatement()
.executeQuery("SELECT * FROM TEST");
assertTrue(rs.next());
assertFalse(rs.next());
new AssertThrows(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1) {
@Override
public void test() throws SQLException {
// must fail when the database is in use
Backup.main("-file", fileName, "-dir", getBaseDir(), "-db",
"testBackupRestore");
}
};
conn.close();
DeleteDbFiles.main("-dir", getBaseDir(), "-db", "testBackupRestore",
"-quiet");
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:37,代码来源:TestTools.java
示例17: 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
示例18: testChangeFileEncryptionWithWrongPassword
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
private void testChangeFileEncryptionWithWrongPassword() throws SQLException {
if (config.mvStore) {
// the file system encryption abstraction used by the MVStore
// doesn't detect wrong passwords
return;
}
org.h2.Driver.load();
final String dir = getBaseDir();
// TODO: this doesn't seem to work in MVSTORE mode yet
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();
// try with wrong password, this used to have a bug where it kept the
// file handle open
new AssertThrows(SQLException.class) {
@Override
public void test() throws SQLException {
ChangeFileEncryption.execute(dir, "testChangeFileEncryption",
"AES", "wrong".toCharArray(),
"def".toCharArray(), true);
}
};
ChangeFileEncryption.execute(dir, "testChangeFileEncryption",
"AES", "abc".toCharArray(), "def".toCharArray(),
true);
conn = getConnection(url, "sa", "def 123");
stat = conn.createStatement();
stat.execute("SELECT * FROM TEST");
conn.close();
String[] args = new String[] { "-dir", dir, "-db", "testChangeFileEncryption", "-quiet" };
DeleteDbFiles.main(args);
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:38,代码来源:TestTools.java
示例19: deleteDb
import org.h2.tools.DeleteDbFiles; //导入依赖的package包/类
/**
* Delete all database files for a database.
*
* @param dir the directory where the database files are located
* @param name the database name
*/
protected void deleteDb(String dir, String name) {
DeleteDbFiles.execute(dir, name, true);
// ArrayList<String> list;
// list = FileLister.getDatabaseFiles(baseDir, name, true);
// if (list.size() > 0) {
// System.out.println("Not deleted: " + list);
// }
}
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:TestBase.java
示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论