@Before public void before() { JdbcDataSource ds = new JdbcDataSource(); ds.setURL("jdbc:h2:/tmp/test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL"); DBI dbi = new DBI(ds); this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList( new Index("/pair", "key"), new Index("/users", "name"), new Index("/users", "age") ) ); try { this.jsondb.dropTables(); } catch (Exception e) { } this.jsondb.createTables(); }
public SqlJsonDB(DBI dbi, EventBus bus, Collection<Index> indexes) { this.dbi = dbi; this.bus = bus; this.indexes = indexes; for (Index index : indexes) { this.indexPaths.add(index.getPath()+"/#"+index.getField()); } // Lets find out the type of DB we are working with. withTransaction(x -> { try { String dbName = x.getConnection().getMetaData().getDatabaseProductName(); databaseKind = DatabaseKind.valueOf(dbName); // CockroachDB uses the PostgreSQL driver.. so need to look a little closer. if( databaseKind == DatabaseKind.PostgreSQL ) { String version = x.createQuery("SELECT VERSION()").mapTo(String.class).first(); if( version.startsWith("CockroachDB") ) { databaseKind = DatabaseKind.CockroachDB; } } } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) { throw new IllegalStateException("Could not determine the database type", e); } }); }
public SqlJsonDB(DBI dbi, EventBus bus, Collection<Index> indexes) { this.dbi = dbi; this.bus = bus; for (Index index : indexes) { this.indexes.add(index.getPath()+"/"+index.getField()); } // Lets find out the type of DB we are working with. withTransaction(x -> { try { String dbName = x.getConnection().getMetaData().getDatabaseProductName(); databaseKind = DatabaseKind.valueOf(dbName); // CockroachDB uses the PostgreSQL driver.. so need to look a little closer. if( databaseKind == DatabaseKind.PostgreSQL ) { String version = x.createQuery("SELECT VERSION()").mapTo(String.class).first(); if( version.startsWith("CockroachDB") ) { databaseKind = DatabaseKind.CockroachDB; } } } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) { throw new IllegalStateException("Could not determine the database type", e); } }); }
@Before public void before() { JdbcDataSource ds = new JdbcDataSource(); ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL"); DBI dbi = new DBI(ds); this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList(new Index("/pair", "key")) ); try { this.jsondb.dropTables(); } catch (Exception e) { } this.jsondb.createTables(); }
@Before public void before() throws IOException, ParseException { JdbcDataSource ds = new JdbcDataSource(); ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL"); DBI dbi = new DBI(ds); this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList(new Index("/pair", "key")) ); try { this.jsondb.dropTables(); } catch (Exception e) { } this.jsondb.createTables(); jsondbRM = new JsonDBRawMetrics(jsondb); load(); CacheManager cacheManager = new LRUCacheManager(100); EncryptionComponent encryptionComponent = new EncryptionComponent(null); ResourceLoader resourceLoader = new DefaultResourceLoader(); //Create Data Manager dataManager = new DataManager(cacheManager, Collections.emptyList(), null, encryptionComponent, resourceLoader); intMH = new IntegrationMetricsHandler(dataManager); }