本文整理汇总了Java中io.vertx.rxjava.ext.jdbc.JDBCClient类的典型用法代码示例。如果您正苦于以下问题:Java JDBCClient类的具体用法?Java JDBCClient怎么用?Java JDBCClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDBCClient类属于io.vertx.rxjava.ext.jdbc包,在下文中一共展示了JDBCClient类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.rxjava.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) {
super.start();
// creates the jdbc client.
jdbc = JDBCClient.createNonShared(vertx, config());
// TODO
// ----
Single<MessageConsumer<JsonObject>> readySingle = Single.error(new UnsupportedOperationException("not yet implemented"));
// ----
readySingle.doOnSuccess(consumer -> {
// on success we set the handler that will store message in the database
consumer.handler(message -> storeInDatabase(message.body()));
}).subscribe(consumer -> {
// complete the verticle start with a success
future.complete();
}, error -> {
// signal a verticle start failure
future.fail(error);
});
}
开发者ID:cescoffier,项目名称:vertx-microservices-workshop,代码行数:31,代码来源:AuditVerticle.java
示例2: WikiDatabaseServiceImpl
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
WikiDatabaseServiceImpl(io.vertx.ext.jdbc.JDBCClient dbClient, HashMap<SqlQuery, String> sqlQueries, Handler<AsyncResult<WikiDatabaseService>> readyHandler) {
this.dbClient = new JDBCClient(dbClient);
this.sqlQueries = sqlQueries;
getConnection()
.flatMap(conn -> conn.rxExecute(sqlQueries.get(SqlQuery.CREATE_PAGES_TABLE)))
.map(v -> this)
.subscribe(RxHelper.toSubscriber(readyHandler));
}
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:10,代码来源:WikiDatabaseServiceImpl.java
示例3: initDatabase
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
public static Completable initDatabase(Vertx vertx, JDBCClient jdbc) {
return jdbc.rxGetConnection()
.flatMapCompletable(connection ->
vertx.fileSystem().rxReadFile("ddl.sql")
.flatMapObservable(buffer -> Observable.from(buffer.toString().split(";")))
.flatMapSingle(connection::rxExecute)
.doAfterTerminate(connection::close)
.toCompletable()
);
}
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:11,代码来源:DBInitHelper.java
示例4: start
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
@Override
public void start() {
// Create a router object.
Router router = Router.router(vertx);
// enable parsing of request bodies
router.route().handler(BodyHandler.create());
// perform validation of the :id parameter
router.route("/api/fruits/:id")
.handler(this::validateId);
// implement a basic REST CRUD mapping
router.get("/api/fruits").handler(this::retrieveAll);
router.post("/api/fruits").handler(this::addOne);
router.get("/api/fruits/:id").handler(this::getOne);
router.put("/api/fruits/:id").handler(this::updateOne);
router.delete("/api/fruits/:id").handler(this::deleteOne);
// health check
router.get("/health").handler(rc -> rc.response().end("OK"));
// web interface
router.get().handler(StaticHandler.create());
// Create a JDBC client
JDBCClient jdbc = JDBCClient.createShared(vertx, new JsonObject()
.put("url", "jdbc:postgresql://" + getEnv("MY_DATABASE_SERVICE_HOST", "localhost") + ":5432/my_data")
.put("driver_class", "org.postgresql.Driver")
.put("user", getEnv("DB_USERNAME", "user"))
.put("password", getEnv("DB_PASSWORD", "password"))
);
DBInitHelper.initDatabase(vertx, jdbc)
.andThen(initHttpServer(router, jdbc))
.subscribe(
(http) -> System.out.println("Server ready on port " + http.actualPort()),
Throwable::printStackTrace
);
}
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:38,代码来源:CrudApplication.java
示例5: initHttpServer
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
private Single<HttpServer> initHttpServer(Router router, JDBCClient client) {
store = new JdbcProductStore(client);
// Create the HTTP server and pass the "accept" method to the request handler.
return vertx
.createHttpServer()
.requestHandler(router::accept)
.rxListen(8080);
}
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:9,代码来源:CrudApplication.java
示例6: CartEventDataSourceImpl
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
public CartEventDataSourceImpl(io.vertx.core.Vertx vertx, JsonObject json) {
this.client = JDBCClient.createNonShared(Vertx.newInstance(vertx), json);
// TODO: Should not init the table here.
client.rxGetConnection()
.flatMap(connection ->
connection.rxExecute(INIT_STATEMENT)
.doAfterTerminate(connection::close)
)
.subscribe();
}
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:11,代码来源:CartEventDataSourceImpl.java
示例7: start
import io.vertx.rxjava.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) {
super.start();
// creates the jdbc client.
jdbc = JDBCClient.createNonShared(vertx, config());
// ----
Single<Void> databaseReady = initializeDatabase(config().getBoolean("drop", false));
Single<Void> httpEndpointReady = configureTheHTTPServer()
.flatMap(server -> rxPublishHttpEndpoint("audit", "localhost", server.actualPort()));
Single<MessageConsumer<JsonObject>> messageConsumerReady = retrieveThePortfolioMessageSource();
Single<MessageConsumer<JsonObject>> readySingle = Single.zip(
databaseReady,
httpEndpointReady,
messageConsumerReady,
(db, http, consumer) -> consumer);
// ----
readySingle.doOnSuccess(consumer -> {
// on success we set the handler that will store message in the database
consumer.handler(message -> storeInDatabase(message.body()));
}).subscribe(consumer -> {
// complete the verticle start with a success
future.complete();
}, error -> {
// signal a verticle start failure
future.fail(error);
});
}
开发者ID:cescoffier,项目名称:vertx-microservices-workshop,代码行数:38,代码来源:AuditVerticle.java
示例8: createDbClient
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
protected SQLClient createDbClient(JsonObject config) {
return JDBCClient.createNonShared(vertx, new JsonObject()
.put("url", config.getString("db_url", "jdbc:hsqldb:file:db/wiki"))
.put("driver_class", config.getString("db_driver", "org.hsqldb.jdbcDriver"))
.put("max_pool_size", config.getInteger("db_max_pool_size", 30)));
}
开发者ID:FroMage,项目名称:redpipe,代码行数:7,代码来源:Server.java
示例9: DatabaseServiceImpl
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
protected DatabaseServiceImpl(Vertx vertx, JsonObject config) {
if (config.containsKey("mysql")) {
this.client = JDBCClient.createShared(vertx, config.getJsonObject("mysql"));
}
}
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:6,代码来源:DatabaseServiceImpl.java
示例10: LocalDatabase
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
private LocalDatabase(Vertx vertx, JsonObject config) {
database = createDatabase(config);
this.client = JDBCClient.createShared(vertx, config);
}
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:5,代码来源:LocalDatabase.java
示例11: BaseDbRxWrapper
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
public BaseDbRxWrapper(Vertx vertx, JsonObject config) {
this.client = JDBCClient
.createNonShared(new io.vertx.rxjava.core.Vertx(vertx), config.getJsonObject("jdbc", config));
// TODO: 23.08.2017 get keys from (global?) .properties
}
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:6,代码来源:BaseDbRxWrapper.java
示例12: JdbcProductStore
import io.vertx.rxjava.ext.jdbc.JDBCClient; //导入依赖的package包/类
public JdbcProductStore(JDBCClient db) {
this.db = db;
}
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:4,代码来源:JdbcProductStore.java
注:本文中的io.vertx.rxjava.ext.jdbc.JDBCClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论