Example #1
0
 public static Database getDefaultHsqlDatabase(final String initDbFile) {
   if (dataSource == null) {
     dataSource = new jdbcDataSource();
     // dataSource.setDatabase("jdbc:hsqldb:hsql://localhost/squilldemodb");
     dataSource.setDatabase("jdbc:hsqldb:mem:squilldemodb");
     dataSource.setUser("SA");
     initDb(dataSource, initDbFile);
   }
   return new Database(dataSource);
 }
Example #2
0
 /////////////// private
 private DataSource getDataSource() throws Exception {
   FileSystem fs = getFileSystem();
   jdbcDataSource ds = new jdbcDataSource();
   ds.setDatabase("jdbc:hsqldb:.");
   ds.setUser("sa");
   ds.setPassword("");
   if (!DatabaseUtils.hasTable(ds, "ledge_id_table")) {
     DatabaseUtils.runScript(ds, fs.getReader("sql/database/IdGeneratorTables.sql", "UTF-8"));
   }
   if (!DatabaseUtils.hasTable(ds, "ledge_naming_context")) {
     DatabaseUtils.runScript(ds, fs.getReader("sql/naming/DBNamingTables.sql", "UTF-8"));
   }
   DatabaseUtils.runScript(ds, fs.getReader("sql/naming/DBNamingTest.sql", "UTF-8"));
   return ds;
 }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    assert gridName != null;

    IgniteConfiguration cfg = super.getConfiguration(gridName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(discoSpi);

    if (gridName.contains("cache")) {
      String cacheName = "test-checkpoints";

      CacheConfiguration cacheCfg = defaultCacheConfiguration();

      cacheCfg.setName(cacheName);
      cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

      CacheCheckpointSpi spi = new CacheCheckpointSpi();

      spi.setCacheName(cacheName);

      cfg.setCacheConfiguration(cacheCfg);

      cfg.setCheckpointSpi(spi);
    } else if (gridName.contains("jdbc")) {
      JdbcCheckpointSpi spi = new JdbcCheckpointSpi();

      jdbcDataSource ds = new jdbcDataSource();

      ds.setDatabase("jdbc:hsqldb:mem:gg_test_" + getClass().getSimpleName());
      ds.setUser("sa");
      ds.setPassword("");

      spi.setDataSource(ds);
      spi.setCheckpointTableName("test_checkpoints");
      spi.setKeyFieldName("key");
      spi.setValueFieldName("value");
      spi.setValueFieldType("longvarbinary");
      spi.setExpireDateFieldName("expire_date");

      cfg.setCheckpointSpi(spi);
    }

    return cfg;
  }
Example #4
0
 public static void shutDownHsql() {
   if (dataSource != null) {
     Connection con = null;
     Statement stmt = null;
     try {
       con = dataSource.getConnection();
       stmt = con.createStatement();
       stmt.execute("shutdown");
     } catch (SQLException e) {
       if (log.isErrorEnabled()) log.error("Error shutting down hsql", e);
     } finally {
       Database.closeIt(con, stmt, null);
       dataSource = null;
     }
   }
 }
Example #5
0
 private static void initDb(jdbcDataSource dataSource, final String initDbFile) {
   Connection con = null;
   try {
     String result = readResource(initDbFile);
     con = dataSource.getConnection();
     final Statement stmt = con.createStatement();
     stmt.execute(result);
   } catch (SQLException sqle) {
     throw new RuntimeException("Error running init scripts", sqle);
   } finally {
     if (con != null)
       try {
         con.close();
       } catch (SQLException e) {
         // ignore
       }
   }
 }