use of com.oracle.adbaoverjdbc.JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES in project oracle-db-examples by oracle.
the class MultiOperationTest method multiRowOperationWithRowHandler.
/**
* Execute a query returning a single result.
*/
@Test
public void multiRowOperationWithRowHandler() {
fail("TODO: Fix this test");
Properties props = new Properties();
DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME);
try (DataSource ds = factory.builder().url(URL).username(USER).password(PASSWORD).sessionProperty(JDBC_CONNECTION_PROPERTIES, props).build();
Session session = ds.getSession(t -> fail("ERROR: " + t.getMessage()))) {
assertNotNull(session);
MultiOperation multiOp = session.multiOperation("select * from forum_user").onError(t -> {
fail(t.toString());
});
BiConsumer<Integer, RowOperation<Integer>> rowHandler = (resNum, rowOp) -> {
assertTrue(resNum > 0);
rowOp.collect(Collector.<Result.RowColumn, int[], Integer>of(() -> new int[1], (int[] a, Result.RowColumn r) -> {
a[0] = a[0] + r.at("sal").get(Integer.class);
}, (l, r) -> l, a -> (Integer) a[0])).onError(t -> {
fail(t.toString());
}).submit().getCompletionStage().thenAccept(n -> {
assertTrue((long) n > 0);
}).toCompletableFuture();
};
multiOp.onRows(rowHandler).submit().getCompletionStage().toCompletableFuture().get(TestConfig.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of com.oracle.adbaoverjdbc.JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES in project oracle-db-examples by oracle-samples.
the class MultiOperationTest method multiRowOperationWithRowHandler.
/**
* Execute a query returning a single result.
*/
@Test
public void multiRowOperationWithRowHandler() {
fail("TODO: Fix this test");
Properties props = new Properties();
DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME);
try (DataSource ds = factory.builder().url(URL).username(USER).password(PASSWORD).sessionProperty(JDBC_CONNECTION_PROPERTIES, props).build();
Session session = ds.getSession(t -> fail("ERROR: " + t.getMessage()))) {
assertNotNull(session);
MultiOperation multiOp = session.multiOperation("select * from forum_user").onError(t -> {
fail(t.toString());
});
BiConsumer<Integer, RowOperation<Integer>> rowHandler = (resNum, rowOp) -> {
assertTrue(resNum > 0);
rowOp.collect(Collector.<Result.RowColumn, int[], Integer>of(() -> new int[1], (int[] a, Result.RowColumn r) -> {
a[0] = a[0] + r.at("sal").get(Integer.class);
}, (l, r) -> l, a -> (Integer) a[0])).onError(t -> {
fail(t.toString());
}).submit().getCompletionStage().thenAccept(n -> {
assertTrue((long) n > 0);
}).toCompletableFuture();
};
multiOp.onRows(rowHandler).submit().getCompletionStage().toCompletableFuture().get(TestConfig.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
fail(e.getMessage());
}
}
Aggregations