问题描述
出于测试目的,我正在使用HSQLDB 2.2.9版.当我在内存数据库中创建命名的文件时,调用shutdown函数后不会删除文件.在我的文件系统上,我有文件夹DBname.tmp和文件DBname.lck,DBname.log,DBname.properties和DBname.script.据我了解,文档( http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_connection_url )应该不会发生.
I'm using HSQLDB version 2.2.9 for testing purposes.When I create named in memory database, files aren't deleted after calling shutdown function. On my filesystem I have folder DBname.tmp and files DBname.lck, DBname.log, DBname.properties and DBname.script. As I understand documentation (http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_connection_url) it shouldn't happened.
为了进行测试,我使用以下代码:
For testing I'm using the following code:
import java.io.IOException;
import org.hsqldb.Server;
import org.hsqldb.persist.HsqlProperties;
import org.hsqldb.server.ServerAcl.AclFormatException;
import org.junit.Test;
public class HSQLDBInMemTest {
@Test
public void test() throws IOException, AclFormatException {
HsqlProperties props = new HsqlProperties();
props.setProperty("server.database.0", "test1");
props.setProperty("server.dbname.0", "test1");
props.setProperty("server.database.1", "test2");
props.setProperty("server.dbname.1", "test2");
Server hsqlServer = new Server();
hsqlServer.setRestartOnShutdown(false);
hsqlServer.setNoSystemExit(true);
hsqlServer.setProperties(props);
hsqlServer.start();
hsqlServer.shutdown();
}
}
推荐答案
代码应类似于:
import java.io.IOException;
import org.hsqldb.Server;
import org.hsqldb.persist.HsqlProperties;
import org.hsqldb.server.ServerAcl.AclFormatException;
import org.junit.Test;
public class HSQLDBInMemTest {
@Test
public void test() throws IOException, AclFormatException {
HsqlProperties props = new HsqlProperties();
props.setProperty("server.database.0", "mem:test1");
props.setProperty("server.database.1", "mem:test2");
Server hsqlServer = new Server();
hsqlServer.setRestartOnShutdown(false);
hsqlServer.setNoSystemExit(true);
hsqlServer.setProperties(props);
hsqlServer.start();
hsqlServer.shutdown();
}
}
内存数据库的路径类似于 props.setProperty("server.database.0","mem:test1");
The path for a memory database looks like props.setProperty("server.database.0", "mem:test1");
这篇关于HSQLDB内存模式在关机时不会删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!