Package org.hsqldb

Examples of org.hsqldb.Server

From the 'server.properties' file, options can be set similarly, using a slightly different format.

Here is an example 'server.properties' file:

 server.port=9001 server.database.0=test server.dbname.0=... ... server.database.n=... server.dbname.n=... server.silent=true 
Starting with 1.7.2, Server has been refactored to become a simple JavaBean with non-blocking start() and stop() service methods. It is possible to configure a Server instance through the JavaBean API as well, but this part of the public interface is still under review and will not be finalized or documented fully until the final 1.7.2 release.

Note:

The 'no_system_exit' property is of particular interest.

If a Server instance is to run embedded in, say, an application server, such as when the jdbcDataSource or HsqlServerFactory classes are used, it is typically necessary to avoid calling System.exit() when the Server instance shuts down.

By default, 'no_system_exit' is set:

  1. true when a Server is started directly from the start() method.

  2. false when a Server is started from the main(String[]) method.

These values are natural to their context because the first case allows the JVM to exit by default on Server shutdown when a Server instance is started from a command line environment, whereas the second case prevents a typically unwanted JVM exit on Server shutdown when a Server intance is started as part of a larger framework.

Replaces original Hypersonic source of the same name. @author fredt@users @version 1.8.0 @since 1.7.2 @jmx.mbean description="HSQLDB Server" extends="org.hsqldb.mx.mbean.RegistrationSupportBaseMBean" @jboss.xmbean


      props.setProperty("server.silent", "true");
      props.setProperty("server.no_system_exit", "true");
      props.setProperty("server.port", 27862);
      props.setProperty("server.address", ipAddressOrHostName);

      hsqldbServer = new Server();
      hsqldbServer.setLogWriter(null);
      hsqldbServer.setProperties(props);
      hsqldbServer.start();

      log.debug("started " + config.getDatabaseName() + " in-VM");
View Full Code Here


        if (isNetwork) {
            if (url == null) {
                url = "jdbc:hsqldb:hsql://localhost/test";
            }

            server = new Server();

            server.setDatabaseName(0, "test");
            server.setDatabasePath(0, "mem:test;sql.enforce_strict_size=true");
            server.setLogWriter(null);
            server.setErrWriter(null);
View Full Code Here

    /**
     * @see org.apache.avalon.framework.activity.Initializable#initialize()
     */
    public void initialize() throws Exception
    {
        this.server = new Server();
        this.server.setProperties( this.serverProperties );
    }
View Full Code Here

      props.setProperty("server.silent", "true");
      props.setProperty("server.no_system_exit", "true");
      props.setProperty("server.port", 27862);
      props.setProperty("server.address", ipAddressOrHostName);

      hsqldbServer = new Server();
      hsqldbServer.setLogWriter(null);
      hsqldbServer.setProperties(props);
      hsqldbServer.start();

      log.debug("started " + config.getDatabaseName() + " in-VM");
View Full Code Here

      props.setProperty("server.silent", "true");
      props.setProperty("server.no_system_exit", "true");
      props.setProperty("server.port", 27862);
      props.setProperty("server.address", ipAddressOrHostName);

      hsqldbServer = new Server();
      hsqldbServer.setLogWriter(null);
      hsqldbServer.setProperties(props);
      hsqldbServer.start();

      log.debug("started " + config.getDatabaseName() + " in-VM");
View Full Code Here

      props.setProperty("server.silent", "true");
      props.setProperty("server.no_system_exit", "true");
      props.setProperty("server.port", 27862);
      props.setProperty("server.address", ipAddressOrHostName);
     
      hsqldbServer = new Server();
      hsqldbServer.setLogWriter(null);
      hsqldbServer.setProperties(props);
      hsqldbServer.start();
     
      log.debug("started " + config.getDatabaseName() + " in-VM");
View Full Code Here

   */
  public static Object startHsqldb(final String databaseFile,
      final String databaseName) throws Exception
  {
    // Start DB in new thread, or else it will block us
    final Server server = new Server();
    Thread serverThread = new Thread(THREAD_NAME) {
      public void run() {
        try {
          // Start server
          Logger targetLogger = Logger.getLogger( "org.hsqldb" );
          server.setLogWriter( new PrintWriter(
              new StdOut2Log4jFilter( server.getLogWriter(), log, targetLogger.getEffectiveLevel() )) );
          server.setDatabasePath( 0, databaseFile );
          server.setDatabaseName( 0, databaseName );
          server.setNoSystemExit( true );
          server.setSilent( true );
          server.start();
        } catch (Exception e) {
          log.error( e );
        }
        //log.error("Failed to start database", e);
      }
View Full Code Here

   * @throws Exception
   */
  public static void stopHsqldb(final Object serverObject) throws Exception {
    if ((serverObject != null) && (serverObject instanceof Server))
    {
      final Server server = (Server)serverObject;
      server.shutdown() ;
    }
  }
View Full Code Here

                }
            } catch (NameNotFoundException e) {
            }

            // create the server
            server = new Server();
            // add the silent property
            properties.setProperty(ServerConstants.SC_KEY_SILENT, "true");
            // set the log and error writers
            server.setLogWriter(new HsqlPrintWriter(false));
            server.setErrWriter(new HsqlPrintWriter(true));
View Full Code Here

        url = "jdbc:hsqldb:hsql://localhost:" + port + "/" + databaseName;
        logger.info("Starting Hypersonic Database '" + url + "'.");
        new Thread() {
            public void run() {
                Server server = new Server();
                server.setDatabasePath(0, "target/hsql/" + databaseName);
                server.setDatabaseName(0, databaseName);
                server.setNoSystemExit( true );
                server.setSilent( true );
                server.setPort(port);
                server.start();
                hsqlServer = server;
            }
        }.start();
        while(hsqlServer == null) {
            Thread.sleep(50);
View Full Code Here

TOP

Related Classes of org.hsqldb.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.