HSQLDB inmemory mode doesn't delete files on shutdown

微笑、不失礼 提交于 2019-12-11 04:24:47

问题


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();
    }
}

回答1:


Answered here: http://sourceforge.net/mailarchive/message.php?msg_id=30881908 by fredt

The code should look like:

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();
}
}

The path for a memory database looks like props.setProperty("server.database.0", "mem:test1");



来源:https://stackoverflow.com/questions/16694067/hsqldb-inmemory-mode-doesnt-delete-files-on-shutdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!