org.hsqldb.Server Java Examples
The following examples show how to use
org.hsqldb.Server.
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: HerokuDatabasePropertiesProviderResourceTest.java From tomee with Apache License 2.0 | 6 votes |
@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 #2
Source File: HsqldbServer.java From lemon with Apache License 2.0 | 6 votes |
@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 #3
Source File: JdbcHdfsDatabaseConfiguration.java From spring-cloud-task-app-starters with Apache License 2.0 | 6 votes |
@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 #4
Source File: SqoopToolDatabaseConfiguration.java From spring-cloud-task-app-starters with Apache License 2.0 | 6 votes |
@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 #5
Source File: HsqldbListener.java From lemon with Apache License 2.0 | 6 votes |
/** * 处理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 #6
Source File: JqmBaseTest.java From jqm with Apache License 2.0 | 6 votes |
@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 #7
Source File: AbstractHsqldbMojo.java From hsqldb-maven-plugin with Apache License 2.0 | 5 votes |
protected void setup() throws MojoExecutionException { if (getLog().isDebugEnabled()) { getLog().debug("Setting up HSQLDB server with :"); getLog().debug("\taddress : " + address); getLog().debug("\tport : " + (port == 0 ? "default" : port)); getLog().debug("\tname : " + name); getLog().debug("\tpath : " + path); getLog().debug("\tconnection URI : " + getConnectionURI()); getLog().debug("\tdriver : " + driver); getLog().debug("\tvalidation query : " + validationQuery); getLog().debug("\tskip : " + skip); } try { server = new Server(); // TODO : user Maven logger server.setLogWriter(null); server.setSilent(true); server.setAddress(address); if (port > 0) { server.setPort(port); } server.setDatabaseName(0, name); server.setDatabasePath(0, path); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
Example #8
Source File: DBCountPageView.java From hadoop-gpu with Apache License 2.0 | 5 votes |
private void startHsqldbServer() { server = new Server(); server.setDatabasePath(0, System.getProperty("test.build.data",".") + "/URLAccess"); server.setDatabaseName(0, "URLAccess"); server.start(); }
Example #9
Source File: DBCountPageView.java From hadoop-book with Apache License 2.0 | 5 votes |
private void startHsqldbServer() { server = new Server(); server.setDatabasePath(0, System.getProperty("test.build.data", ".") + "/URLAccess"); server.setDatabaseName(0, "URLAccess"); server.start(); }
Example #10
Source File: Common.java From jqm with Apache License 2.0 | 5 votes |
static Properties dbProperties(Server s) { Properties p = new Properties(); p.put("com.enioka.jqm.jdbc.allowSchemaUpdate", "true"); p.put("com.enioka.jqm.jdbc.datasource", "jdbc/jqm"); return p; }
Example #11
Source File: Common.java From jqm with Apache License 2.0 | 5 votes |
static Server createHsqlServer() { Server s = new Server(); String dbName = "testdb_" + Math.random(); s.setDatabaseName(0, dbName); s.setDatabasePath(0, "mem:" + dbName); s.setLogWriter(null); s.setSilent(true); return s; }
Example #12
Source File: DBCountPageView.java From RDFS with Apache License 2.0 | 5 votes |
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: TestDBStorage.java From spork with Apache License 2.0 | 5 votes |
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 #14
Source File: MockDatabase.java From soabase with Apache License 2.0 | 5 votes |
@SuppressWarnings("ParameterCanBeLocal") public static void main(String[] args) throws Exception { ExampleAppBase.checkNullConsole(); args = new String[] { "--database.0", "mem:test", "--dbname.0", "xdb", "--port", "10064" }; Server.main(args); SqlSession session; try (InputStream stream = Resources.getResource("example-mybatis.xml").openStream()) { SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(stream); Configuration mybatisConfiguration = sqlSessionFactory.getConfiguration(); mybatisConfiguration.addMapper(AttributeEntityMapper.class); session = sqlSessionFactory.openSession(true); } AttributeEntityMapper mapper = session.getMapper(AttributeEntityMapper.class); mapper.createTable(); mapper.insert(new AttributeEntity("test", "global")); mapper.insert(new AttributeEntity("test2", "hello", "one")); mapper.insert(new AttributeEntity("test2", "goodbye", "two")); List<AttributeEntity> attributeEntities = mapper.selectAll(); System.out.println(attributeEntities); System.out.println("Running..."); Thread.currentThread().join(); }
Example #15
Source File: HsqldbServer.java From scheduling with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void startUp() throws Exception { server = new Server(); server.setProperties(hsqlProperties); server.setErrWriter(null); server.setLogWriter(null); server.start(); }
Example #16
Source File: HsqlTestUtils.java From CogStack-Pipeline with Apache License 2.0 | 5 votes |
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 #17
Source File: HsqlTestUtils.java From CogStack-Pipeline with Apache License 2.0 | 4 votes |
public static Server getServer1() { return server1; }
Example #18
Source File: DbTest.java From netcrusher-java with Apache License 2.0 | 4 votes |
@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); }
Example #19
Source File: HsqlTestUtils.java From CogStack-Pipeline with Apache License 2.0 | 4 votes |
public static void setServer2(Server server2) { HsqlTestUtils.server2 = server2; }
Example #20
Source File: HsqlTestUtils.java From CogStack-Pipeline with Apache License 2.0 | 4 votes |
public static Server getServer2() { return server2; }
Example #21
Source File: HsqlTestUtils.java From CogStack-Pipeline with Apache License 2.0 | 4 votes |
public static void setServer1(Server server1) { HsqlTestUtils.server1 = server1; }