本文整理汇总了Java中io.vertx.ext.jdbc.JDBCClient.createNonShared方法的典型用法代码示例。如果您正苦于以下问题:Java JDBCClient.createNonShared方法的具体用法?Java JDBCClient.createNonShared怎么用?Java JDBCClient.createNonShared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.jdbc.JDBCClient
的用法示例。
在下文中一共展示了JDBCClient.createNonShared方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStockTradesPersisted
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Test
public void testStockTradesPersisted(TestContext context) throws ClassNotFoundException {
Async async = context.async();
JsonObject jdbcConfig = new JsonObject(config.getObject("jdbc").render(ConfigRenderOptions.concise()));
JDBCClient jdbc = JDBCClient.createNonShared(vertx, jdbcConfig);
Class.forName(jdbcConfig.getString("driverclass"));
jdbc.getConnection(ar -> {
SQLConnection connection = ar.result();
if (ar.failed()) {
context.fail(ar.cause());
} else {
connection.query(SELECT_STATEMENT, result -> {
ResultSet set = result.result();
List<JsonObject> operations = set.getRows().stream()
.map(json -> new JsonObject(json.getString("OPERATION")))
.collect(Collectors.toList());
context.assertTrue(operations.size() >= 3);
connection.close();
async.complete();
});
}
});
}
示例2: start
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> future) throws Exception {
super.start();
jdbcClient = JDBCClient.createNonShared(vertx.getDelegate(), config().getJsonObject("jdbc"));
DatabaseService database = DatabaseService.create(vertx.getDelegate(), config());
consumer = registerService(DatabaseService.class, vertx.getDelegate(), database, ADDRESS);
startEBRouter(DatabaseService.ADDRESS, DatabaseService.class, future);
// TODO: 3.09.2017 setup security for public users (getallusers should not be available for everyone)
}
示例3: start
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
/**
* Starts the verticle asynchronously. The the initialization is completed, it calls
* `complete()` on the given {@link Future} object. If something wrong happens,
* `fail` is called.
*
* @param future the future to indicate the completion
*/
@Override
public void start(Future<Void> future) throws ClassNotFoundException {
super.start();
// Get configuration
config = ConfigFactory.load();
// creates the jdbc client.
JsonObject jdbcConfig = new JsonObject(config.getObject("jdbc").render(ConfigRenderOptions.concise()));
jdbc = JDBCClient.createNonShared(vertx, jdbcConfig);
Class.forName(jdbcConfig.getString("driverclass"));
// Start HTTP server and listen for portfolio events
EventBus eventBus = vertx.eventBus();
Future<HttpServer> httpEndpointReady = configureTheHTTPServer();
httpEndpointReady.setHandler(ar -> {
if (ar.succeeded()) {
MessageConsumer<JsonObject> portfolioConsumer = eventBus.consumer(config.getString("portfolio.address"));
portfolioConsumer.handler(message -> {
storeInDatabase(message.body());
});
future.complete();
} else {
future.fail(ar.cause());
}
});
publishHttpEndpoint("audit", config.getString("http.host"), config.getInt("http.public.port"), config.getString("http.root"), ar -> {
if (ar.failed()) {
ar.cause().printStackTrace();
} else {
System.out.println("Audit (Rest endpoint) service published : " + ar.succeeded());
}
});
}
示例4: retrieve
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Override
public JDBCClient retrieve() {
JsonObject result = record().getMetadata().copy();
result.mergeIn(record().getLocation());
if (config != null) {
result.mergeIn(config);
}
if (result.getBoolean("shared", false)) {
return JDBCClient.createShared(vertx, result);
} else {
return JDBCClient.createNonShared(vertx, result);
}
}
示例5: continuingConnectionAttempts
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Test
public void continuingConnectionAttempts() {
client = JDBCClient.createNonShared(vertx, config());
vertx.setTimer(2000, res -> {
testComplete();
});
client.getConnection(ar -> {
fail("Should not get invoked");
});
await();
}
示例6: stopConnectionAttempts
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Test
public void stopConnectionAttempts() {
JsonObject config = config().put("acquire_retry_attempts", 1).put("break_after_acquire_failure", true);
client = JDBCClient.createNonShared(vertx, config);
vertx.setTimer(2000, res -> {
fail("Should not get invoked");
});
client.getConnection(onFailure(t -> {
assertThat(t, instanceOf(SQLException.class));
testComplete();
}));
await();
}
示例7: createProvider
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Override
public JDBCAuth createProvider(Vertx vertx) {
JDBCClient client;
if (shared) {
if (datasourceName != null) {
client = JDBCClient.createShared(vertx, config, datasourceName);
} else {
client = JDBCClient.createShared(vertx, config);
}
} else {
client = JDBCClient.createNonShared(vertx, config);
}
JDBCAuth auth = JDBCAuth.create(vertx, client);
if (authenticationQuery != null) {
auth.setAuthenticationQuery(authenticationQuery);
}
if (rolesQuery != null) {
auth.setRolesQuery(rolesQuery);
}
if (permissionsQuery != null) {
auth.setPermissionsQuery(permissionsQuery);
}
if (rolesPrefix != null) {
auth.setRolePrefix(rolesPrefix);
}
return auth;
}
示例8: PaymentQueryServiceImpl
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public PaymentQueryServiceImpl(Vertx vertx, JsonObject config) {
this.jdbc = JDBCClient.createNonShared(vertx, config);
}
示例9: JdbcRepositoryWrapper
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public JdbcRepositoryWrapper(Vertx vertx, JsonObject config) {
this.client = JDBCClient.createNonShared(vertx, config);
}
示例10: createProvider
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
protected JDBCAuth createProvider() {
JDBCClient client = JDBCClient.createNonShared(vertx, config());
return JDBCAuth.create(vertx, client);
}
示例11: VertxJdbcClientImpl
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public VertxJdbcClientImpl(Vertx vertx, JdbcOptionsBean config) {
jdbcClient = JDBCClient.createNonShared(vertx, parseConfig(config));
}
示例12: exampleCreateNonShared
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void exampleCreateNonShared(Vertx vertx, JsonObject config) {
SQLClient client = JDBCClient.createNonShared(vertx, config);
}