当前位置: 首页>>代码示例>>Java>>正文


Java JDBCClient.createShared方法代码示例

本文整理汇总了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());
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:20,代码来源:WikiDatabaseVerticle.java

示例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());
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:20,代码来源:WikiDatabaseVerticle.java

示例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;
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:29,代码来源:MainVerticle.java

示例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();
        }
      });
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:33,代码来源:WikiDatabaseVerticle.java

示例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
        )
    ));
}
 
开发者ID:codefacts,项目名称:Elastic-Components,代码行数:11,代码来源:Test.java

示例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);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:16,代码来源:JDBCDataSourceImpl.java

示例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");
  }

}
 
开发者ID:aesteve,项目名称:nubes,代码行数:29,代码来源:Config.java

示例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;
}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:28,代码来源:JDBCAuthOptions.java

示例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;
    }
 
开发者ID:codefacts,项目名称:Elastic-Components,代码行数:27,代码来源:TrackerExporter.java

示例10: VertxJdbcClientImpl

import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public VertxJdbcClientImpl(Vertx vertx, String dsName, JdbcOptionsBean config) {
    jdbcClient = JDBCClient.createShared(vertx, parseConfig(config), dsName);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:4,代码来源:VertxJdbcClientImpl.java

示例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);

  }
 
开发者ID:vert-x3,项目名称:vertx-jdbc-client,代码行数:11,代码来源:JDBCExamples.java

示例12: exampleCreateDefault

import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void exampleCreateDefault(Vertx vertx, JsonObject config) {

    SQLClient client = JDBCClient.createShared(vertx, config);

  }
 
开发者ID:vert-x3,项目名称:vertx-jdbc-client,代码行数:6,代码来源:JDBCExamples.java

示例13: exampleCreateDataSourceName

import io.vertx.ext.jdbc.JDBCClient; //导入方法依赖的package包/类
public void exampleCreateDataSourceName(Vertx vertx, JsonObject config) {


    SQLClient client = JDBCClient.createShared(vertx, config, "MyDataSource");

  }
 
开发者ID:vert-x3,项目名称:vertx-jdbc-client,代码行数:7,代码来源:JDBCExamples.java

示例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);
  }
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:7,代码来源:AuthJDBCExamples.java


注:本文中的io.vertx.ext.jdbc.JDBCClient.createShared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。