本文整理汇总了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);
}
}
示例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;
}
示例3: DbiManagerImpl
import org.skife.jdbi.v2.DBI; //导入方法依赖的package包/类
@Inject
public DbiManagerImpl(DBI dbi) {
this.dbi = dbi;
dbi.setSQLLog(new SLF4JLog(logger, Level.TRACE));
}
示例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;
}