KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > server > HSqlDBServer


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.server;
5
6 import org.hsqldb.HsqlProperties;
7 import org.hsqldb.Server;
8 import org.hsqldb.ServerConfiguration;
9
10
11 // Mainly copy from HsqlDBServer class of dso-spring-tests modules.
12
public class HSqlDBServer {
13   private static final String JavaDoc 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 JavaDoc {
23     HsqlProperties hsqlproperties1 = new HsqlProperties();
24     HsqlProperties hsqlproperties2 = HsqlProperties.argArrayToProps(new String JavaDoc[]{
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 JavaDoc {
37     server.setNoSystemExit(true);
38     server.stop();
39   }
40 }
41
Popular Tags