Tabnine Logo
DBI.setSQLLog
Code IndexAdd Tabnine to your IDE (free)

How to use
setSQLLog
method
in
org.skife.jdbi.v2.DBI

Best Java code snippets using org.skife.jdbi.v2.DBI.setSQLLog (Showing top 19 results out of 315)

origin: jooby-project/jooby

@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);
 }
}
origin: dropwizard/dropwizard

dbi.setSQLLog(new LogbackLog(LOGGER, Level.TRACE));
origin: bwajtr/java-persistence-frameworks-comparison

@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;
}
origin: stackoverflow.com

SqlObjectRepository() {
  _dbiInstance = new DBI(_connectionHelper.getDataSource());
  _dbiInstance.setSQLLog(new Log4JLog());
origin: org.jooby/jooby-jdbi

@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);
 }
}
origin: org.kill-bill.commons/killbill-jdbi

@Override
public IDBI get() {
  final DBI dbi = new DBI(ds);
  for (final ArgumentFactory argumentFactory : argumentFactorySet) {
    dbi.registerArgumentFactory(argumentFactory);
  }
  for (final ResultSetMapperFactory resultSetMapperFactory : resultSetMapperFactorySet) {
    dbi.registerMapper(resultSetMapperFactory);
  }
  for (final ResultSetMapper resultSetMapper : resultSetMapperSet) {
    dbi.registerMapper(resultSetMapper);
  }
  if (transactionHandler != null) {
    dbi.setTransactionHandler(transactionHandler);
  }
  if (sqlLog != null) {
    dbi.setSQLLog(sqlLog);
  } else if (config != null) {
    final Slf4jLogging sqlLog = new Slf4jLogging(logger, config.getLogLevel());
    dbi.setSQLLog(sqlLog);
  }
  if (timingCollector != null) {
    dbi.setTimingCollector(timingCollector);
  }
  return dbi;
}
origin: org.jdbi/jdbi

@Before
public void setUp() throws Exception
{
  dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  dbi.setSQLLog(new PrintStreamLog(System.out));
  handle = dbi.open();
  handle.execute("create table something( id integer primary key, name varchar(100) )");
}
origin: org.jdbi/jdbi

@Before
public void setUp() throws Exception
{
  dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  dbi.setSQLLog(new PrintStreamLog(System.out));
  handle = dbi.open();
  handle.execute("create table something( id integer primary key, name varchar(100) )");
}
origin: org.kill-bill.commons/killbill-jdbi

@Before
public void setUp() throws Exception
{
  dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  dbi.setSQLLog(new PrintStreamLog(System.out));
  handle = dbi.open();
  handle.execute("create table something( id integer primary key, name varchar(100) )");
}
origin: org.kill-bill.commons/killbill-jdbi

@Before
public void setUp() throws Exception
{
  dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  dbi.setSQLLog(new PrintStreamLog(System.out));
  handle = dbi.open();
  handle.execute("create table something( id integer primary key, name varchar(100) )");
}
origin: org.jdbi/jdbi

@Before
public void setUp() throws Exception
{
  dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  dbi.setSQLLog(new PrintStreamLog(System.out));
  handle = dbi.open();
  handle.execute("create table something( id integer primary key, name varchar(100) )");
  handle.execute("CREATE ALIAS stored_insert FOR \"org.skife.jdbi.v2.sqlobject.TestSqlCall.insertSomething\";");
}
origin: org.kill-bill.commons/killbill-jdbi

@Before
public void setUp() throws Exception
{
  dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  dbi.registerMapper(new SomethingMapper());
  dbi.setSQLLog(new PrintStreamLog(System.out));
  handle = dbi.open();
  handle.execute("create table something( id integer primary key, name varchar(100) )");
  handle.execute("CREATE ALIAS stored_insert FOR \"org.skife.jdbi.v2.sqlobject.TestSqlCall.insertSomething\";");
}
origin: com.hubspot/BlazarData

@Override
public DBI get() {
 final DBI dbi = new DBI(transactionalDataSource);
 dbi.setSQLLog(new LogbackLog());
 if (environment.isPresent()) {
  environment.get().lifecycle().manage(managedDataSource);
  environment.get().healthChecks().register("db", new DBIHealthCheck(dbi, dataSourceFactory.getValidationQuery()));
  dbi.setTimingCollector(new InstrumentedTimingCollector(environment.get().metrics(), new SanerNamingStrategy()));
 }
 dbi.registerArgumentFactory(new OptionalArgumentFactory(dataSourceFactory.getDriverClass()));
 dbi.registerContainerFactory(new ImmutableListContainerFactory());
 dbi.registerContainerFactory(new ImmutableSetContainerFactory());
 dbi.registerContainerFactory(new OptionalContainerFactory());
 dbi.registerArgumentFactory(new JodaDateTimeArgumentFactory());
 dbi.registerMapper(new JodaDateTimeMapper());
 dbi.registerMapper(new RosettaMapperFactory());
 new RosettaObjectMapperOverride(objectMapper).override(dbi);
 return dbi;
}
origin: org.jdbi/jdbi

@Before
public void setUp() throws Exception {
  JdbcDataSource ds = new JdbcDataSource();
  ds.setURL("jdbc:h2:mem:" + UUID.randomUUID());
  DBI dbi = new DBI(ds);
  dbi.setSQLLog(new PrintStreamLog());
  handle = dbi.open();
  somethingDao = handle.attach(SomethingDao.class);
  handle.execute("create table something (something_id int primary key, name varchar(100), code int)");
  handle.execute("insert into something(something_id, name, code) values (1, 'Brian', 12)");
  handle.execute("insert into something(something_id, name, code) values (2, 'Keith', 27)");
  handle.execute("insert into something(something_id, name, code) values (3, 'Coda', 14)");
}
origin: org.kill-bill.billing/killbill-osgi

@Override
public DataSource get() {
  final DataSource ds = getDataSource();
  final DBI dbi = new DBI(ds);
  dbi.registerArgumentFactory(new UUIDArgumentFactory());
  dbi.registerArgumentFactory(new DateTimeZoneArgumentFactory());
  dbi.registerArgumentFactory(new DateTimeArgumentFactory());
  dbi.registerArgumentFactory(new LocalDateArgumentFactory());
  dbi.registerArgumentFactory(new EnumArgumentFactory());
  dbi.registerMapper(new UuidMapper());
  if (sqlLog != null) {
    dbi.setSQLLog(sqlLog);
  }
  return ds;
}
origin: org.kill-bill.commons/killbill-jdbi

@Before
public void setUp() throws Exception {
  JdbcDataSource ds = new JdbcDataSource();
  ds.setURL("jdbc:h2:mem:" + UUID.randomUUID());
  DBI dbi = new DBI(ds);
  dbi.setSQLLog(new PrintStreamLog());
  handle = dbi.open();
  somethingDao = handle.attach(SomethingDao.class);
  handle.execute("create table something (something_id int primary key, name varchar(100), code int)");
  handle.execute("insert into something(something_id, name, code) values (1, 'Brian', 12)");
  handle.execute("insert into something(something_id, name, code) values (2, 'Keith', 27)");
  handle.execute("insert into something(something_id, name, code) values (3, 'Coda', 14)");
}
origin: jvelo/mayocat-shop

private void registerDBIFactoryComponent(Environment environment, MayocatShopSettings configuration)
    throws ClassNotFoundException, ComponentRepositoryException
{
  final DBIFactory factory = new DBIFactory();
  final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "jdbi");
  jdbi.registerArgumentFactory(new PostgresUUIDArgumentFactory());
  jdbi.registerArgumentFactory(new PostgresUUIDArrayArgumentFactory());
  if (configuration.getDevelopmentEnvironment().isEnabled() &&
      configuration.getDevelopmentEnvironment().isLogDatabaseRequests())
  {
    jdbi.setSQLLog(new PrintStreamLog());
  }
  final DBIProvider dbi = new DBIProvider()
  {
    @Override
    public DBI get()
    {
      return jdbi;
    }
  };
  DefaultComponentDescriptor<DBIProvider> cd = new DefaultComponentDescriptor<DBIProvider>();
  cd.setRoleType(DBIProvider.class);
  getComponentManager().registerComponent(cd, dbi);
}
origin: com.ning.jetty/ning-service-skeleton-jdbi

final DBI dbi = new DBI(ds);
if (sqlLog != null) {
  dbi.setSQLLog(sqlLog);
origin: io.dropwizard/dropwizard-jdbi

dbi.setSQLLog(new LogbackLog(LOGGER, Level.TRACE));
org.skife.jdbi.v2DBIsetSQLLog

Javadoc

Specify the class used to log sql statements. Will be passed to all handles created from this instance

Popular methods of DBI

  • <init>
    Constructor used to allow for obtaining a Connection in a customized manner. The org.skife.jdbi.v2.t
  • open
  • onDemand
    Create a new sql object which will obtain and release connections from this dbi instance, as it need
  • registerMapper
    Register a result set mapper which will have its parameterized type inspected to determine what it m
  • withHandle
    A convenience function which manages the lifecycle of a handle and yields it to a callback for use b
  • registerArgumentFactory
  • inTransaction
  • registerContainerFactory
  • setStatementLocator
    Use a non-standard StatementLocator to look up named statements for all handles created from this DB
  • setStatementRewriter
    Use a non-standard StatementRewriter to transform SQL for all Handle instances created by this DBI.
  • setTransactionHandler
    Specify the TransactionHandler instance to use. This allows overriding transaction semantics, or map
  • setTimingCollector
    Add a callback to accumulate timing information about the queries running from this data source.
  • setTransactionHandler,
  • setTimingCollector,
  • useHandle,
  • define,
  • close,
  • getStatementLocator,
  • getTransactionHandler,
  • registerColumnMapper

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setRequestProperty (URLConnection)
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Collectors (java.util.stream)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now