本文整理汇总了Java中io.vertx.ext.jdbc.JDBCClient.createShared方法的典型用法代码示例。如果您正苦于以下问题:Java JDBCClient.createShared方法的具体用法?Java JDBCClient.createShared怎么用?Java JDBCClient.createShared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.jdbc.JDBCClient
的用法示例。
在下文中一共展示了JDBCClient.createShared方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
HashMap<SqlQuery, String> sqlQueries = loadSqlQueries();
JDBCClient dbClient = JDBCClient.createShared(vertx, new JsonObject()
.put("url", config().getString(CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:file:db/wiki"))
.put("driver_class", config().getString(CONFIG_WIKIDB_JDBC_DRIVER_CLASS, "org.hsqldb.jdbcDriver"))
.put("max_pool_size", config().getInteger(CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 30)));
WikiDatabaseService.create(dbClient, sqlQueries, ready -> {
if (ready.succeeded()) {
ProxyHelper.registerService(WikiDatabaseService.class, vertx, ready.result(), CONFIG_WIKIDB_QUEUE);
startFuture.complete();
} else {
startFuture.fail(ready.cause());
}
});
}
示例2: start
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
HashMap<SqlQuery, String> sqlQueries = loadSqlQueries();
JDBCClient dbClient = JDBCClient.createShared(vertx, new JsonObject()
.put("url", config().getString(CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:file:db/wiki"))
.put("driver_class", config().getString(CONFIG_WIKIDB_JDBC_DRIVER_CLASS, "org.hsqldb.jdbcDriver"))
.put("max_pool_size", config().getInteger(CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 30)));
WikiDatabaseService.create(dbClient, sqlQueries, ready -> {
if (ready.succeeded()) {
ProxyHelper.registerService(WikiDatabaseService.class, vertx, ready.result(), CONFIG_WIKIDB_QUEUE); // <1>
startFuture.complete();
} else {
startFuture.fail(ready.cause());
}
});
}
示例3: prepareDatabase
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
private Future<Void> prepareDatabase() {
Future<Void> future = Future.future();
dbClient = JDBCClient.createShared(vertx, new JsonObject() // <1>
.put("url", "jdbc:hsqldb:file:db/wiki") // <2>
.put("driver_class", "org.hsqldb.jdbcDriver") // <3>
.put("max_pool_size", 30)); // <4>
dbClient.getConnection(ar -> { // <5>
if (ar.failed()) {
LOGGER.error("Could not open a database connection", ar.cause());
future.fail(ar.cause()); // <6>
} else {
SQLConnection connection = ar.result(); // <7>
connection.execute(SQL_CREATE_PAGES_TABLE, create -> {
connection.close(); // <8>
if (create.failed()) {
LOGGER.error("Database preparation error", create.cause());
future.fail(create.cause());
} else {
future.complete(); // <9>
}
});
}
});
return future;
}
示例4: start
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
/*
* Note: this uses blocking APIs, but data is small...
*/
loadSqlQueries(); // <1>
dbClient = JDBCClient.createShared(vertx, new JsonObject()
.put("url", config().getString(CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:file:db/wiki"))
.put("driver_class", config().getString(CONFIG_WIKIDB_JDBC_DRIVER_CLASS, "org.hsqldb.jdbcDriver"))
.put("max_pool_size", config().getInteger(CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 30)));
dbClient.getConnection(ar -> {
if (ar.failed()) {
LOGGER.error("Could not open a database connection", ar.cause());
startFuture.fail(ar.cause());
} else {
SQLConnection connection = ar.result();
connection.execute(sqlQueries.get(SqlQuery.CREATE_PAGES_TABLE), create -> { // <2>
connection.close();
if (create.failed()) {
LOGGER.error("Database preparation error", create.cause());
startFuture.fail(create.cause());
} else {
vertx.eventBus().consumer(config().getString(CONFIG_WIKIDB_QUEUE, "wikidb.queue"), this::onMessage); // <3>
startFuture.complete();
}
});
}
});
}
示例5: jdbcClient
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
static JDBCClient jdbcClient(String db, Vertx vertx) {
return JDBCClient.createShared(vertx, new JsonObject(
ImmutableMap.of(
"user", "root",
"password", "",
"driver_class", "com.mysql.jdbc.Driver",
"url", "jdbc:mysql://localhost/" + db
)
));
}
示例6: 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);
}
}
示例7: createAuthHandlers
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
private void createAuthHandlers() {
String auth = json.getString("auth-type");
JsonObject authProperties = json.getJsonObject("auth-properties");
// TODO : discuss it. I'm really not convinced about all the boilerplate needed in config (dbName only for JDBC, etc.)
if (authProperties != null) {
// For now, only JWT,Shiro and JDBC supported (same as for Vert.x web)
switch (auth) {
case "JWT":// For now only allow properties realm
this.authProvider = JWTAuth.create(vertx, authProperties);
break;
case "Shiro":
ShiroAuth.create(vertx, new ShiroAuthOptions(authProperties));
break;
case "JDBC":
String dbName = json.getString("db-name");
Objects.requireNonNull(dbName);
JDBCClient client = JDBCClient.createShared(vertx, authProperties, dbName);
this.authProvider = JDBCAuth.create(client);
break;
default:
LOG.warn("Unknown type of auth : " + auth + " . Ignoring.");
}
} else if (auth != null) {
LOG.warn("You have defined " + auth + " as auth type, but didn't provide any configuration, can't create authProvider");
}
}
示例8: 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;
}
示例9: exportTo
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
static ModuleSystemBuilder exportTo(ExportToParams params) {
Objects.requireNonNull(params);
final ModuleSystemBuilder builder = params.getBuilder();
final App.Config config = params.getConfig();
final JDBCClient jdbcClient = JDBCClient.createShared(config.getVertx(), config.getDb());
params.getBuilder().export(App.Config.class, module -> module.export(config));
params.getBuilder().export(JDBCClient.class, module -> module.export(jdbcClient));
builder.export(Vertx.class, module -> module.export(module.require(App.Config.class).getVertx()));
builder.export(EventBus.class, module -> module.export(module.require(Vertx.class).eventBus()));
exportOrm(builder, jdbcClient);
exportAppComponents(builder, config);
exportExtraComponents(builder, config);
EntityToStateHandlersMapExporter.exportTo(builder);
return builder;
}
示例10: VertxJdbcClientImpl
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public VertxJdbcClientImpl(Vertx vertx, String dsName, JdbcOptionsBean config) {
jdbcClient = JDBCClient.createShared(vertx, parseConfig(config), dsName);
}
示例11: example5
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void example5(Vertx vertx) {
JsonObject config = new JsonObject()
.put("url", "jdbc:hsqldb:mem:test?shutdown=true")
.put("driver_class", "org.hsqldb.jdbcDriver")
.put("max_pool_size", 30);
SQLClient client = JDBCClient.createShared(vertx, config);
}
示例12: exampleCreateDefault
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void exampleCreateDefault(Vertx vertx, JsonObject config) {
SQLClient client = JDBCClient.createShared(vertx, config);
}
示例13: exampleCreateDataSourceName
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void exampleCreateDataSourceName(Vertx vertx, JsonObject config) {
SQLClient client = JDBCClient.createShared(vertx, config, "MyDataSource");
}
示例14: example5
import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void example5(Vertx vertx, JsonObject jdbcClientConfig) {
JDBCClient jdbcClient = JDBCClient.createShared(vertx, jdbcClientConfig);
JDBCAuth authProvider = JDBCAuth.create(vertx, jdbcClient);
}