本文整理匯總了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;
}