Java Code Examples for org.hsqldb.Server#start()

The following examples show how to use org.hsqldb.Server#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdbcHdfsDatabaseConfiguration.java    From spring-cloud-task-app-starters with Apache License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "stop")
public Server databaseServer() throws SQLException, IOException, ServerAcl.AclFormatException {
	DriverManager.registerDriver(new org.hsqldb.jdbcDriver());
	int hsqldbPort = SocketUtils.findAvailableTcpPort(10000);
	System.setProperty("db.server.port", Integer.toString(hsqldbPort));
	logger.info("Database is using port: " + Integer.toString(hsqldbPort));
	HsqlProperties configProps = new HsqlProperties();
	configProps.setProperty("server.port", hsqldbPort);
	configProps.setProperty("server.database.0", "file:target/db/test");
	configProps.setProperty("server.dbname.0", "test");
	Server server = new Server();
	server.setLogWriter(null);
	server.setErrWriter(null);
	server.setRestartOnShutdown(false);
	server.setNoSystemExit(true);
	server.setProperties(configProps);
	server.start();
	return server;
}
 
Example 2
Source File: SqoopToolDatabaseConfiguration.java    From spring-cloud-task-app-starters with Apache License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "stop")
public Server databaseServer() throws SQLException, IOException {
	DriverManager.registerDriver(new org.hsqldb.jdbcDriver());
	int hsqldbPort = SocketUtils.findAvailableTcpPort(10000);
	System.setProperty("db.server.port", Integer.toString(hsqldbPort));
	logger.info("Database is using port: " + Integer.toString(hsqldbPort));
	HsqlProperties configProps = new HsqlProperties();
	configProps.setProperty("server.port", hsqldbPort);
	configProps.setProperty("server.database.0", "file:target/db/test");
	configProps.setProperty("server.dbname.0", "test");
	Server server = new org.hsqldb.Server();
	server.setLogWriter(null);
	server.setErrWriter(null);
	server.setRestartOnShutdown(false);
	server.setNoSystemExit(true);
	server.setProperties(configProps);
	server.start();
	return server;
}
 
Example 3
Source File: JqmBaseTest.java    From jqm with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void testInit() throws Exception
{
    if (db == null)
    {
        JndiContext.createJndiContext();

        // If needed, create an HSQLDB server.
        String dbName = System.getenv("DB");
        if (dbName == null || "hsqldb".equals(dbName))
        {
            s = new Server();
            s.setDatabaseName(0, "testdbengine");
            s.setDatabasePath(0, "mem:testdbengine");
            s.setLogWriter(null);
            s.setSilent(true);
            s.start();
        }

        // In all cases load the datasource. (the helper itself will load the property file if any).
        db = Helpers.getDb();
    }
}
 
Example 4
Source File: HsqldbListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 处理context初始化事件.
 * 
 * @param sce
 *            ServletContextEvent
 */
public void contextInitialized(ServletContextEvent sce) {
    if (!enabled) {
        logger.info("skip hsqldb server");

        return;
    }

    try {
        String databasePath = path + "/" + databaseName;
        url = "jdbc:hsqldb:hsql://localhost:" + port + "/" + databaseName;

        Server server = new Server();
        server.setDatabaseName(0, databaseName);

        server.setDatabasePath(0, databasePath);
        server.setPort(port);
        server.setSilent(true);
        server.start();
        Thread.sleep(WAIT_TIME);
    } catch (InterruptedException ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example 5
Source File: HsqldbServer.java    From lemon with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    if (!enabled) {
        logger.info("skip hsqldb server");

        return;
    }

    try {
        String databasePath = path + "/" + databaseName;
        url = "jdbc:hsqldb:hsql://localhost:" + port + "/" + databaseName;

        Server server = new Server();
        server.setDatabaseName(0, databaseName);

        server.setDatabasePath(0, databasePath);
        server.setPort(port);
        server.setSilent(true);
        server.start();
        Thread.sleep(WAIT_TIME);
    } catch (InterruptedException ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example 6
Source File: HerokuDatabasePropertiesProviderResourceTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            final int port = NetworkUtil.getNextAvailablePort();
            final Server server = new Server();
            server.setAddress("localhost");
            server.setPort(port);
            server.setDatabaseName(0, "adb");
            server.setDatabasePath(0, Files.mkdirs(new File("target/HerokuDatabasePropertiesProviderResourceTest")).getAbsolutePath());
            server.start();
            System.setProperty("hsqldb", Integer.toString(port));
            try {
                base.evaluate();
            } finally {
                server.stop();
            }
        }
    };
}
 
Example 7
Source File: HsqlTestUtils.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
public static void initHSQLDBs() throws IOException, ServerAcl.AclFormatException {

       HsqlProperties p1 = new HsqlProperties();
       p1.setProperty("server.database.0", "mem:hsqldb");
       p1.setProperty("server.dbname.0", "minicogs");
       p1.setProperty("server.port", "9001");
       p1.setProperty("server.remote_open", "true");
       server1 = new Server();
       server1.setProperties(p1);
       server1.setLogWriter(null);
       server1.setErrWriter(null);
       server1.start();

       HsqlProperties p2 = new HsqlProperties();
       p2.setProperty("server.database.0", "mem:hsqldb");
       p2.setProperty("server.dbname.0", "minicogs");
       p2.setProperty("server.port", "9002");
       p2.setProperty("server.remote_open", "true");
       server2 = new Server();
       server2.setProperties(p2);
       server2.setLogWriter(null);
       server2.setErrWriter(null);
       server2.start();

       //yodieconfig
       //Properties prop = System.getProperties();
       //prop.setProperty("at.ofai.gate.modularpipelines.configFile", "/home/rich/gate-apps/yodie/yodie-pipeline/main-bio/main-bio.config.yaml");        
   }
 
Example 8
Source File: HsqldbServer.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void startUp() throws Exception {
    server = new Server();
    server.setProperties(hsqlProperties);
    server.setErrWriter(null);
    server.setLogWriter(null);
    server.start();
}
 
Example 9
Source File: TestDBStorage.java    From spork with Apache License 2.0 5 votes vote down vote up
public TestDBStorage() throws ExecException, IOException {
    // Initialise Pig server
    cluster = MiniCluster.buildCluster();
    pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    pigServer.getPigContext().getProperties()
            .setProperty(MRConfiguration.MAP_MAX_ATTEMPTS, "1");
    pigServer.getPigContext().getProperties()
            .setProperty(MRConfiguration.REDUCE_MAX_ATTEMPTS, "1");
    System.out.println("Pig server initialized successfully");
    TMP_DIR = System.getProperty("user.dir") + "/build/test/";
    dblocation = TMP_DIR + "batchtest";
    url = "jdbc:hsqldb:file:" + dblocation
           + ";hsqldb.default_table_type=cached;hsqldb.cache_rows=100";
    // Initialise DBServer
    dbServer = new Server();
    dbServer.setDatabaseName(0, "batchtest");
    // dbServer.setDatabasePath(0, "mem:test;sql.enforce_strict_size=true");
    dbServer.setDatabasePath(0,
                        "file:" + TMP_DIR + "batchtest;sql.enforce_strict_size=true");
    dbServer.setLogWriter(null);
    dbServer.setErrWriter(null);
    dbServer.start();
    System.out.println("Database URL: " + dbUrl);
    try {
        Class.forName(driver);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println(this + ".setUp() error: " + e.getMessage());
    }
    System.out.println("Database server started on port: " + dbServer.getPort());
}
 
Example 10
Source File: DBCountPageView.java    From RDFS with Apache License 2.0 5 votes vote down vote up
private void startHsqldbServer() {
  server = new Server();
  server.setDatabasePath(0, 
      System.getProperty("test.build.data",".") + "/URLAccess");
  server.setDatabaseName(0, "URLAccess");
  server.start();
}
 
Example 11
Source File: DBCountPageView.java    From hadoop-book with Apache License 2.0 5 votes vote down vote up
private void startHsqldbServer() {
    server = new Server();
    server.setDatabasePath(0,
            System.getProperty("test.build.data", ".") + "/URLAccess");
    server.setDatabaseName(0, "URLAccess");
    server.start();
}
 
Example 12
Source File: DBCountPageView.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
private void startHsqldbServer() {
  server = new Server();
  server.setDatabasePath(0, 
      System.getProperty("test.build.data",".") + "/URLAccess");
  server.setDatabaseName(0, "URLAccess");
  server.start();
}
 
Example 13
Source File: DbTest.java    From netcrusher-java with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    reactor = new NioReactor();

    crusher = TcpCrusherBuilder.builder()
            .withReactor(reactor)
            .withBindAddress("127.0.0.1", CRUSHER_PORT)
            .withConnectAddress("127.0.0.1", DB_PORT)
            .buildAndOpen();

    hsqlServer = new Server();
    hsqlServer.setAddress("127.0.0.1");
    hsqlServer.setPort(DB_PORT);
    hsqlServer.setDaemon(true);
    hsqlServer.setErrWriter(new PrintWriter(System.err));
    hsqlServer.setLogWriter(new PrintWriter(System.out));
    hsqlServer.setNoSystemExit(true);
    hsqlServer.setDatabasePath(0, "mem:testdb");
    hsqlServer.setDatabaseName(0, "testdb");
    hsqlServer.start();

    Class.forName("org.hsqldb.jdbc.JDBCDriver");

    BoneCPConfig config = new BoneCPConfig();
    config.setJdbcUrl(String.format("jdbc:hsqldb:hsql://127.0.0.1:%d/testdb", CRUSHER_PORT));
    config.setUsername("sa");
    config.setPassword("");
    config.setInitSQL(SQL_CHECK);
    config.setConnectionTestStatement(SQL_CHECK);
    config.setAcquireIncrement(1);
    config.setAcquireRetryAttempts(1);
    config.setAcquireRetryDelayInMs(1000);
    config.setConnectionTimeoutInMs(1000);
    config.setQueryExecuteTimeLimitInMs(1000);
    config.setDefaultAutoCommit(false);
    config.setDefaultReadOnly(true);
    config.setDefaultTransactionIsolation("NONE");
    config.setPartitionCount(1);
    config.setMinConnectionsPerPartition(1);
    config.setMaxConnectionsPerPartition(1);
    config.setLazyInit(true);
    config.setDetectUnclosedStatements(true);

    connectionPool = new BoneCP(config);
}