1 4 package com.tctest.server; 5 6 import org.hsqldb.HsqlProperties; 7 import org.hsqldb.Server; 8 import org.hsqldb.ServerConfiguration; 9 10 11 public class HSqlDBServer { 13 private static final String DEFAULT_DB_NAME = "testdb"; 14 private static final int DEFAULT_PORT = 9001; 15 16 private Server server; 17 18 public HSqlDBServer() { 19 super(); 20 } 21 22 public void start() throws Exception { 23 HsqlProperties hsqlproperties1 = new HsqlProperties(); 24 HsqlProperties hsqlproperties2 = HsqlProperties.argArrayToProps(new String []{ 25 "-database.0", "mem:testdb", 26 "-dbname.0", DEFAULT_DB_NAME, 27 "server.port", "" + DEFAULT_PORT 28 }, "server"); 29 hsqlproperties1.addProperties(hsqlproperties2); 30 ServerConfiguration.translateDefaultDatabaseProperty(hsqlproperties1); 31 server = new Server(); 32 server.setProperties(hsqlproperties1); 33 server.start(); 34 } 35 36 public void stop() throws Exception { 37 server.setNoSystemExit(true); 38 server.stop(); 39 } 40 } 41 | Popular Tags |