2013-05-22 45 views
1

我正在使用HSQLDB 2.2.9版進行測試。 當我在內存數據庫中創建named時,調用shutdown函數後文件不會被刪除。在我的文件系統上,我有文件夾DBname.tmp和文件DBname.lck,DBname.log,DBname.properties和DBname.script。據我瞭解文件(http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_connection_url)它不應該發生。HSQLDB inmemory模式不會在關機時刪除文件

爲了測試我使用下面的代碼:

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

回答

0

在這裏找到答案:http://sourceforge.net/mailarchive/message.php?msg_id=30881908通過fredt

代碼應該是這樣的:

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