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


Java DBI.setSQLLog方法代码示例

本文整理汇总了Java中org.skife.jdbi.v2.DBI.setSQLLog方法的典型用法代码示例。如果您正苦于以下问题:Java DBI.setSQLLog方法的具体用法?Java DBI.setSQLLog怎么用?Java DBI.setSQLLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.skife.jdbi.v2.DBI的用法示例。


在下文中一共展示了DBI.setSQLLog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.skife.jdbi.v2.DBI; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void configure(final Env env, final Config config, final Binder binder) {
  Key<DataSource> dskey = Key.get(DataSource.class, Names.named(name));
  DataSource ds = env.get(dskey)
      .orElseThrow(() -> new NoSuchElementException("DataSource missing: " + dskey));

  DBI dbi = new DBI2(ds);
  dbi.setSQLLog(new SLF4JLog());
  dbi.registerArgumentFactory(new OptionalArgumentFactory());
  dbi.registerArgumentFactory(new IterableArgumentFactory());
  dbi.registerContainerFactory(new OptionalContainerFactory());
  dbi.setStatementRewriter(new ExpandedStmtRewriter());

  ServiceKey serviceKey = env.serviceKey();
  serviceKey.generate(DBI.class, name, k -> binder.bind(k).toInstance(dbi));
  serviceKey.generate(Handle.class, name, k -> binder.bind(k).toProvider(() -> dbi.open()));

  sqlObjects.forEach(sqlObject -> binder.bind(sqlObject)
      .toProvider((Provider) () -> dbi.open(sqlObject)));

  if (callback != null) {
    callback.accept(dbi, config);
  }
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:Jdbi.java

示例2: jdbiFactory

import org.skife.jdbi.v2.DBI; //导入方法依赖的package包/类
@SuppressWarnings("SpringJavaAutowiringInspection")
@Bean
public DBI jdbiFactory(DataSource dataSource) {
    // note that for JDBI we have to wrap datasource with TransactionAwareDataSourceProxy otherwise JDBI won't respect
    // transactions created by spring
    TransactionAwareDataSourceProxy transactionAwareDataSourceProxy = new TransactionAwareDataSourceProxy(dataSource);
    DBI dbi = new DBI(transactionAwareDataSourceProxy);
    dbi.setSQLLog(new SLF4JLog());  // to enable SLF4J logging
    return dbi;
}
 
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:11,代码来源:DbTestsApplication.java

示例3: DbiManagerImpl

import org.skife.jdbi.v2.DBI; //导入方法依赖的package包/类
@Inject
public DbiManagerImpl(DBI dbi) {
	this.dbi = dbi;
	dbi.setSQLLog(new SLF4JLog(logger, Level.TRACE));
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:6,代码来源:DbiManagerImpl.java

示例4: newDBI

import org.skife.jdbi.v2.DBI; //导入方法依赖的package包/类
/**
 * Create a new {@code DBI} instance.
 * <br>
 * The created instance will log to the baseline service log,
 * and collects timing metrics.
 *
 * @param dataSource instance of {@code DataSource} from which database connections are sourced
 * @return valid, new {@code DBI} instance
 */
public static DBI newDBI(DataSource dataSource) {
    DBI dbi = new DBI(dataSource);

    dbi.setSQLLog(new LogbackSQLLog());
    dbi.setTimingCollector(new InstrumentedTimingCollector(MetricRegistries.getRegistry()));

    return dbi;
}
 
开发者ID:redbooth,项目名称:baseline,代码行数:18,代码来源:Databases.java


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