Java Code Examples for org.hsqldb.persist.HsqlProperties#setProperty()

The following examples show how to use org.hsqldb.persist.HsqlProperties#setProperty() . 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: HsqlDatabaseServer.java    From tessera with Apache License 2.0 5 votes vote down vote up
@Override
public void start() {

    HsqlProperties properties = new HsqlProperties();
    for (int i = 0; i < 4; i++) {
        String db = nodeId + (i + 1);
        properties.setProperty("server.database." + i, "file:target/hsql/" + db);
        properties.setProperty("server.dbname." + i, db);
    }
    
    properties.setProperty("server.database.4", "file:target/hsql/rest-httpwhitelist5");
    properties.setProperty("server.dbname.4", "rest-httpwhitelist5");

    hsqlServer.setPort(9189);
    hsqlServer.setSilent(true);
    hsqlServer.setTrace(false);
    try{
        hsqlServer.setProperties(properties);
    } catch (IOException | ServerAcl.AclFormatException ex) {
        throw new RuntimeException(ex);
    }
    hsqlServer.start();
    if(hsqlServer.isNotRunning()) {
        throw new IllegalStateException("HSQL DB not started. ");
    }

}
 
Example 4
Source File: ServerConfiguration.java    From evosql with Apache License 2.0 5 votes vote down vote up
/**
 * Translates null or zero length value for address key to the
 * special value ServerConstants.SC_DEFAULT_ADDRESS which causes
 * ServerSockets to be constructed without specifying an InetAddress.
 *
 * @param p The properties object upon which to perform the translation
 */
public static void translateAddressProperty(HsqlProperties p) {

    if (p == null) {
        return;
    }

    String address = p.getProperty(ServerProperties.sc_key_address);

    if (StringUtil.isEmpty(address)) {
        p.setProperty(ServerProperties.sc_key_address, SC_DEFAULT_ADDRESS);
    }
}
 
Example 5
Source File: ServerConfiguration.java    From evosql with Apache License 2.0 5 votes vote down vote up
/**
 * Translates the legacy default database form: database=...
 * to the 1.7.2 form: database.0=...
 *
 * @param p The properties object upon which to perform the translation
 */
public static void translateDefaultDatabaseProperty(HsqlProperties p) {

    if (p == null) {
        return;
    }

    if (!p.isPropertyTrue(ServerProperties.sc_key_remote_open_db)) {
        if (p.getProperty(ServerProperties.sc_key_database + "." + 0)
                == null) {
            String defaultdb =
                p.getProperty(ServerProperties.sc_key_database);

            if (defaultdb == null) {
                defaultdb = SC_DEFAULT_DATABASE;
            } else {
                p.removeProperty(ServerProperties.sc_key_database);
            }

            p.setProperty(ServerProperties.sc_key_database + ".0",
                          defaultdb);
            p.setProperty(ServerProperties.sc_key_dbname + ".0", "");
        }

        if (p.getProperty(ServerProperties.sc_key_dbname + "." + 0)
                == null) {
            p.setProperty(ServerProperties.sc_key_dbname + ".0", "");
        }
    }
}
 
Example 6
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 7
Source File: DatabaseManager.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new manager.
 * 
 * @param databaseDir
 *          directory to keep the files in.
 * @throws SQLException
 *           if the DAO table cannot be initialized.
 */
public DatabaseManager(File databaseDir) throws SQLException {
	pool = new Stack<Connection>();
	props = new HsqlProperties();
	props.setProperty("connection_type", "file:");
	props.setProperty("database",
			new File(databaseDir, DBNAME).getAbsolutePath());
	daos = new HashMap<Class<?>, Object>();
	daoversions = new HashMap<String, Integer>();

	Connection c = new JDBCConnection(props);
	Statement st = null;
	ResultSet res = null;
	try {
		// Load the DAO version table
		st = c.createStatement();
		st.execute("CREATE TABLE IF NOT EXISTS versions (dao VARCHAR(255), version INT)");
		st.close();

		st = c.createStatement();
		st.execute("SELECT dao, version FROM versions");
		res = st.getResultSet();
		while (res.next()) {
			daoversions.put(res.getString(1), res.getInt(2));
		}
	}
	finally {
		if (res != null) {
			res.close();
		}
		if (st != null) {
			st.close();
		}
		pool.push(c);
	}
}