當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。