本文整理汇总了Java中org.h2.store.fs.FileUtils.deleteRecursive方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.deleteRecursive方法的具体用法?Java FileUtils.deleteRecursive怎么用?Java FileUtils.deleteRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.store.fs.FileUtils
的用法示例。
在下文中一共展示了FileUtils.deleteRecursive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExclusiveLock
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testExclusiveLock() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore;MV_STORE=TRUE;MVCC=FALSE";
Connection conn, conn2;
Statement stat, stat2;
conn = getConnection(dbName);
stat = conn.createStatement();
stat.execute("create table test(id int)");
stat.execute("insert into test values(1)");
conn.setAutoCommit(false);
// stat.execute("update test set id = 2");
stat.executeQuery("select * from test for update");
conn2 = getConnection(dbName);
stat2 = conn2.createStatement();
ResultSet rs2 = stat2.executeQuery(
"select * from information_schema.locks");
assertTrue(rs2.next());
assertEquals("TEST", rs2.getString("table_name"));
assertEquals("WRITE", rs2.getString("lock_type"));
conn2.close();
conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
}
示例2: testEncryption
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testEncryption() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn;
Statement stat;
String url = getURL(dbName + ";CIPHER=AES", true);
String user = "sa";
String password = "123 123";
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement();
stat.execute("create table test(id int primary key)");
conn.close();
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement();
stat.execute("select * from test");
stat.execute("drop table test");
conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
}
示例3: testTwoPhaseCommit
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testTwoPhaseCommit() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("set write_delay 0");
conn.setAutoCommit(false);
stat.execute("insert into test values(1, 'Hello')");
stat.execute("prepare commit test_tx");
stat.execute("shutdown immediately");
JdbcUtils.closeSilently(conn);
conn = getConnection(url);
stat = conn.createStatement();
ResultSet rs;
rs = stat.executeQuery("select * from information_schema.in_doubt");
assertTrue(rs.next());
stat.execute("commit transaction test_tx");
rs = stat.executeQuery("select * from test");
assertTrue(rs.next());
conn.close();
}
示例4: deleteDb
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void deleteDb(String dbName) {
super.deleteDb(dbName);
try {
Utils.callStaticMethod(
"org.h2.upgrade.v1_1.tools.DeleteDbFiles.execute",
getBaseDir(), dbName, true);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
FileUtils.delete(getBaseDir() + "/" +
dbName + ".data.db.backup");
FileUtils.delete(getBaseDir() + "/" +
dbName + ".index.db.backup");
FileUtils.deleteRecursive(getBaseDir() + "/" +
dbName + ".lobs.db.backup", false);
}
示例5: testCreateDropNative
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testCreateDropNative() throws SQLException {
deleteDb("fullText");
FileUtils.deleteRecursive(getBaseDir() + "/fullText", false);
Connection conn = getConnection("fullText");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS IF NOT EXISTS FT_INIT " +
"FOR \"org.h2.fulltext.FullText.init\"");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
for (int i = 0; i < 10; i++) {
FullText.createIndex(conn, "PUBLIC", "TEST", null);
FullText.dropIndex(conn, "PUBLIC", "TEST");
}
conn.close();
deleteDb("fullText");
FileUtils.deleteRecursive(getBaseDir() + "/fullText", false);
}
示例6: testSecondaryIndex
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testSecondaryIndex() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id int)");
int size = 8 * 1024;
stat.execute("insert into test select mod(x * 111, " + size + ") " +
"from system_range(1, " + size + ")");
stat.execute("create index on test(id)");
ResultSet rs = stat.executeQuery(
"select count(*) from test inner join " +
"system_range(1, " + size + ") where " +
"id = mod(x * 111, " + size + ")");
rs.next();
assertEquals(size, rs.getInt(1));
conn.close();
}
示例7: testTimeout
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testTimeout() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Connection conn2;
Statement stat;
Statement stat2;
String url = "mvstore;MV_STORE=TRUE;MVCC=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id identity, name varchar)");
conn2 = getConnection(url);
stat2 = conn2.createStatement();
conn.setAutoCommit(false);
conn2.setAutoCommit(false);
stat.execute("insert into test values(1, 'Hello')");
assertThrows(ErrorCode.LOCK_TIMEOUT_1, stat2).
execute("insert into test values(1, 'Hello')");
conn2.close();
conn.close();
}
示例8: testRollback
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testRollback() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id identity)");
conn.setAutoCommit(false);
stat.execute("insert into test values(1)");
stat.execute("delete from test");
conn.rollback();
conn.close();
}
示例9: main
import org.h2.store.fs.FileUtils; //导入方法依赖的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 {
// delete all files in this directory
FileUtils.deleteRecursive("~/temp", false);
Connection conn;
Class.forName("org.h2.Driver");
// create a database where the database file is split into
// multiple small files, 4 MB each (2^22). The larger the
// parts, the faster opening the database, but also the
// more files. 4 MB seems to be a good compromise, so
// the prefix split:22: is used, which means each part is
// 2^22 bytes long
conn = DriverManager.getConnection(
"jdbc:h2:split:22:~/temp/test");
System.out.println("adding test data...");
Statement stat = conn.createStatement();
stat.execute(
"create table test(id int primary key, name varchar) " +
"as select x, space(1000) from system_range(1, 2000)");
System.out.println("defrag to reduce random access...");
stat.execute("shutdown defrag");
conn.close();
System.out.println("create the zip file...");
Backup.execute("~/temp/test.zip", "~/temp", "", true);
// delete the old database files
DeleteDbFiles.execute("split:~/temp", "test", true);
System.out.println("open the database from the zip file...");
conn = DriverManager.getConnection(
"jdbc:h2:split:zip:~/temp/test.zip!/test");
// the database can now be used
conn.close();
}
示例10: testRecover
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testRecover() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("insert into test values(1, 'Hello')");
stat.execute("create table test2(name varchar)");
stat.execute("insert into test2 values('Hello World')");
conn.close();
Recover.execute(getBaseDir(), "mvstore");
DeleteDbFiles.execute(getBaseDir(), "mvstore", true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("runscript from '" + getBaseDir() + "/mvstore.h2.sql'");
ResultSet rs;
rs = stat.executeQuery("select * from test");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertEquals("Hello", rs.getString(2));
rs = stat.executeQuery("select * from test2");
assertTrue(rs.next());
assertEquals("Hello World", rs.getString(1));
conn.close();
}
示例11: afterTest
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
/**
* Stop the server if it was started.
*/
public void afterTest() {
FileUtils.deleteRecursive("trace.db", true);
if (networked && server != null) {
server.stop();
}
FileUtils.deleteRecursive(TestBase.BASE_TEST_DIR, true);
}
示例12: testReopen
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testReopen(boolean lucene) throws SQLException {
if (config.memory) {
return;
}
String prefix = lucene ? "FTL" : "FT";
deleteDb("fullTextReopen");
FileUtils.deleteRecursive(getBaseDir() + "/fullTextReopen", false);
Connection conn = getConnection("fullTextReopen");
Statement stat = conn.createStatement();
initFullText(stat, lucene);
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello World')");
stat.execute("CALL " + prefix + "_CREATE_INDEX('PUBLIC', 'TEST', NULL)");
stat.execute("UPDATE TEST SET NAME=NULL WHERE ID=1");
stat.execute("UPDATE TEST SET NAME='Hello World' WHERE ID=1");
conn.close();
conn = getConnection("fullTextReopen");
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM " +
prefix + "_SEARCH('Hello', 0, 0)");
assertTrue(rs.next());
stat.executeQuery("SELECT * FROM " + prefix + "_SEARCH(NULL, 0, 0)");
stat.execute("INSERT INTO TEST VALUES(2, NULL)");
conn.close();
FullText.closeAll();
conn = getConnection("fullTextReopen");
stat = conn.createStatement();
stat.execute("INSERT INTO TEST VALUES(3, 'Hello')");
conn.close();
FileUtils.deleteRecursive(getBaseDir() + "/fullTextReopen", false);
}
示例13: testGarbageCollectionForLOB
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testGarbageCollectionForLOB() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id int, data blob)");
stat.execute("insert into test select x, repeat('0', 10000) " +
"from system_range(1, 10)");
stat.execute("drop table test");
stat.equals("call @temp := cast(repeat('0', 10000) as blob)");
stat.execute("create table test2(id int, data blob)");
PreparedStatement prep = conn.prepareStatement(
"insert into test2 values(?, ?)");
prep.setInt(1, 1);
assertThrows(ErrorCode.IO_EXCEPTION_1, prep).
setBinaryStream(1, createFailingStream(new IOException()));
prep.setInt(1, 2);
assertThrows(ErrorCode.IO_EXCEPTION_1, prep).
setBinaryStream(1, createFailingStream(new IllegalStateException()));
conn.close();
MVStore s = MVStore.open(getBaseDir()+ "/mvstore.mv.db");
assertTrue(s.hasMap("lobData"));
MVMap<Long, byte[]> lobData = s.openMap("lobData");
assertEquals(0, lobData.sizeAsLong());
assertTrue(s.hasMap("lobMap"));
MVMap<Long, byte[]> lobMap = s.openMap("lobMap");
assertEquals(0, lobMap.sizeAsLong());
assertTrue(s.hasMap("lobRef"));
MVMap<Long, byte[]> lobRef = s.openMap("lobRef");
assertEquals(0, lobRef.sizeAsLong());
s.close();
}
示例14: testDropIndex
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testDropIndex(boolean lucene) throws SQLException {
if (config.memory) {
return;
}
deleteDb("fullTextDropIndex");
String prefix = lucene ? "FTL" : "FT";
FileUtils.deleteRecursive(getBaseDir() + "/fullTextDropIndex", false);
Connection conn = getConnection("fullTextDropIndex");
Statement stat = conn.createStatement();
initFullText(stat, lucene);
stat.execute("CREATE TABLE TEST" +
"(ID INT PRIMARY KEY, NAME1 VARCHAR, NAME2 VARCHAR)");
stat.execute("INSERT INTO TEST VALUES" +
"(1, 'Hello World', 'Hello Again')");
stat.execute("CALL " + prefix +
"_CREATE_INDEX('PUBLIC', 'TEST', 'NAME1')");
stat.execute("UPDATE TEST SET NAME1=NULL WHERE ID=1");
stat.execute("UPDATE TEST SET NAME1='Hello World' WHERE ID=1");
stat.execute("CALL " + prefix +
"_DROP_INDEX('PUBLIC', 'TEST')");
stat.execute("CALL " + prefix +
"_CREATE_INDEX('PUBLIC', 'TEST', 'NAME1, NAME2')");
stat.execute("UPDATE TEST SET NAME2=NULL WHERE ID=1");
stat.execute("UPDATE TEST SET NAME2='Hello World' WHERE ID=1");
conn.close();
conn.close();
FileUtils.deleteRecursive(getBaseDir() + "/fullTextDropIndex", false);
}
示例15: test
import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void test() throws Exception {
deleteDb("functions");
testDataType();
testVersion();
testFunctionTable();
testFunctionTableVarArgs();
testArrayParameters();
testDefaultConnection();
testFunctionInSchema();
testGreatest();
testSource();
testDynamicArgumentAndReturn();
testUUID();
testWhiteSpacesInParameters();
testSchemaSearchPath();
testDeterministic();
testTransactionId();
testPrecision();
testMathFunctions();
testVarArgs();
testAggregate();
testAggregateType();
testFunctions();
testFileRead();
testValue();
testNvl2();
testConcatWs();
testTruncate();
testToCharFromDateTime();
testToCharFromNumber();
testToCharFromText();
testTranslate();
testGenerateSeries();
// TODO
// testCachingOfDeterministicFunctionAlias();
deleteDb("functions");
FileUtils.deleteRecursive(TEMP_DIR, true);
}