HSQLDB inmemory mode doesn't delete files on s

2019-07-28 15:59发布

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条回答
Luminary・发光体
2楼-- · 2019-07-28 16:53

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");

查看更多
登录 后发表回答