JAVA启动HSQL Server
HSQL启动Server的命令为java -cp hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb
为了方便在JAVA程序中能启动它封装了下类org.hsqldb.Server
import org.hsqldb.Server;import org.hsqldb.ServerConfiguration;import org.hsqldb.ServerConstants;import org.hsqldb.lib.FileUtil;import org.hsqldb.persist.HsqlProperties;public class HSQLServer extends Server {public static void start(String[] args) {String propsPath = FileUtil.canonicalOrAbsolutePath("server");HsqlProperties fileProps = ServerConfiguration.getPropertiesFromFile(propsPath);HsqlProperties props = fileProps == null ? new HsqlProperties(): fileProps;HsqlProperties stringProps = HsqlProperties.argArrayToProps(args,ServerConstants.SC_KEY_PREFIX);if (stringProps != null) {if (stringProps.getErrorKeys().length != 0) {printHelp("server.help");return;}props.addProperties(stringProps);}ServerConfiguration.translateDefaultDatabaseProperty(props);ServerConfiguration.translateDefaultNoSystemExitProperty(props);Server server = new Server();server.setProperties(props);server.start();}}
启动方式为;
String[] args=new String[{"-database.0","file:mydb","-dbname.0","xdb"};HSQLServer.start(args);
页:
[1]