congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DBI.onDemand
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: apache/incubator-druid

@Override
public Iterable<Map.Entry<String, String>> fetch(final Iterable<String> keys)
{
 QueryKeys queryKeys = dbi.onDemand(QueryKeys.class);
 return queryKeys.findNamesForIds(Lists.newArrayList(keys), table, keyColumn, valueColumn);
}
origin: signalapp/Signal-Server

 @Override
 protected void run(Bootstrap<WhisperServerConfiguration> bootstrap,
           Namespace namespace,
           WhisperServerConfiguration config)
   throws Exception
 {
  DataSourceFactory messageDbConfig = config.getMessageStoreConfiguration();
  DBI               messageDbi      = new DBI(messageDbConfig.getUrl(), messageDbConfig.getUser(), messageDbConfig.getPassword());

  messageDbi.registerArgumentFactory(new OptionalArgumentFactory(messageDbConfig.getDriverClass()));
  messageDbi.registerContainerFactory(new ImmutableListContainerFactory());
  messageDbi.registerContainerFactory(new ImmutableSetContainerFactory());
  messageDbi.registerContainerFactory(new OptionalContainerFactory());

  Messages messages  = messageDbi.onDemand(Messages.class);
  long     timestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(90);

  logger.info("Trimming old messages: " + timestamp + "...");
  messages.removeOld(timestamp);

  Thread.sleep(3000);
  System.exit(0);
 }
}
origin: signalapp/Signal-Server

dbi.registerContainerFactory(new OptionalContainerFactory());
Accounts accounts  = dbi.onDemand(Accounts.class);
long     yesterday = TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis()) - 1;
long     monthAgo  = yesterday - 30;
origin: signalapp/Signal-Server

messageDbi.registerContainerFactory(new OptionalContainerFactory());
Accounts        accounts        = dbi.onDemand(Accounts.class       );
Keys            keys            = dbi.onDemand(Keys.class           );
PendingAccounts pendingAccounts = dbi.onDemand(PendingAccounts.class);
Messages        messages        = messageDbi.onDemand(Messages.class);
origin: signalapp/Signal-Server

dbi.registerContainerFactory(new OptionalContainerFactory());
Accounts            accounts        = dbi.onDemand(Accounts.class);
ReplicatedJedisPool cacheClient     = new RedisClientFactory(configuration.getCacheConfiguration().getUrl(), configuration.getCacheConfiguration().getReplicaUrls()).getRedisClientPool();
ReplicatedJedisPool redisClient     = new RedisClientFactory(configuration.getDirectoryConfiguration().getRedisConfiguration().getUrl(), configuration.getDirectoryConfiguration().getRedisConfiguration().getReplicaUrls()).getRedisClientPool();
origin: HubSpot/Singularity

@Override
public PostgresHistoryJDBI get() {
 return dbi.onDemand(PostgresHistoryJDBI.class);
}
origin: HubSpot/Singularity

@Override
public MySQLHistoryJDBI get() {
 return dbi.onDemand(MySQLHistoryJDBI.class);
}
origin: signalapp/Signal-Server

dbi.registerContainerFactory(new OptionalContainerFactory());
Accounts            accounts        = dbi.onDemand(Accounts.class);
ReplicatedJedisPool cacheClient     = new RedisClientFactory(configuration.getCacheConfiguration().getUrl(), configuration.getCacheConfiguration().getReplicaUrls()).getRedisClientPool();
ReplicatedJedisPool redisClient     = new RedisClientFactory(configuration.getDirectoryConfiguration().getRedisConfiguration().getUrl(), configuration.getDirectoryConfiguration().getRedisConfiguration().getReplicaUrls()).getRedisClientPool();
origin: signalapp/Signal-Server

DBI        abusedb    = dbiFactory.build(environment, config.getAbuseDatabaseConfiguration(), "abusedb");
Accounts         accounts         = database.onDemand(Accounts.class       );
PendingAccounts  pendingAccounts  = database.onDemand(PendingAccounts.class);
PendingDevices   pendingDevices   = database.onDemand(PendingDevices.class );
Keys             keys             = database.onDemand(Keys.class           );
Messages         messages         = messagedb.onDemand(Messages.class);
AbusiveHostRules abusiveHostRules = abusedb.onDemand(AbusiveHostRules.class);
origin: k0kubun/gitstar-ranking

  private AccessToken rotateToken()
  {
    if (tokens.isEmpty()) {
      tokens = dbi.onDemand(AccessTokenDao.class).allEnabledTokens();
    }
    return tokens.remove(0); // TODO: handle no tokens
  }
}
origin: k0kubun/gitstar-ranking

public GitHubClient buildForUser(Integer userId)
{
  AccessToken token = dbi.onDemand(AccessTokenDao.class).findByUserId(userId);
  return new GitHubClient(token.getToken());
}
origin: org.jdbi/jdbi

@Test
public void testOnDemandDao() throws Exception
{
  DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID());
  MyDAO dao = dbi.onDemand(MyDAO.class);
}
origin: org.kill-bill.commons/killbill-queue

@BeforeClass(groups = "slow")
public void beforeClass() throws Exception {
  super.beforeClass();
  sqlDao = getDBI().onDemand(PersistentBusSqlDao.class);
}
origin: org.jdbi/jdbi

@Test
public void testFinalizeDoesntConnect() throws Exception
{
  final UselessDao dao = dbi.onDemand(UselessDao.class);
  dao.finalize(); // Normally GC would do this, but just fake it
}
origin: org.jdbi/jdbi

@Test
public void testSimpleTransactionsSucceed() throws Exception
{
  final SomethingDao dao = dbi.onDemand(SomethingDao.class);
  dao.insertInSingleTransaction(10, "Linda");
}
origin: org.jdbi/jdbi

@Test
public void testNoErrorOnNoData() throws Exception
{
  Kabob bob = dbi.onDemand(Kabob.class);
  Something henning = bob.find(1);
  assertThat(henning, nullValue());
  List<Something> rs = bob.listAll();
  assertThat(rs.isEmpty(), equalTo(true));
  Iterator<Something> itty = bob.iterateAll();
  assertThat(itty.hasNext(), equalTo(false));
}
origin: org.jdbi/jdbi

@Test
public void testRegisterMapperAnnotationWorks() throws Exception
{
  Kabob bob = dbi.onDemand(Kabob.class);
  bob.insert(1, "Henning");
  Something henning = bob.find(1);
  assertThat(henning, equalTo(new Something(1, "Henning")));
}
origin: org.jdbi/jdbi

@Test
public void testWithSqlObjectSetReturnValue() throws Exception
{
  Dao dao = dbi.onDemand(Dao.class);
  dao.insert(new Something(1, "Coda"));
  dao.insert(new Something(2, "Brian"));
  Set<String> rs = dao.findAllAsSet();
  assertThat(rs, equalTo((Set<String>)ImmutableSet.of("Coda", "Brian")));
}
origin: org.jdbi/jdbi

@Test
public void testTransactionPropagates() throws Exception
{
  Foo foo = dbi.onDemand(Foo.class);
  try {
    foo.insertAndFail(1, "Jeff");
    fail("should have raised an exception");
  }
  catch (Exception e){}
  Something n = foo.createBar().findById(1);
  assertThat(n, nullValue());
}
origin: org.jdbi/jdbi

@Test
public void testOnDemandSpiffy() throws Exception
{
  Spiffy spiffy = dbi.onDemand(Spiffy.class);
  spiffy.insert(new Something(1, "Tim"));
  spiffy.insert(new Something(2, "Diego"));
  assertEquals("Diego", spiffy.findNameById(2));
}
org.skife.jdbi.v2DBIonDemand

Javadoc

Create a new sql object which will obtain and release connections from this dbi instance, as it needs to, and can, respectively. You should not explicitely close this sql object

Popular methods of DBI

  • <init>
    Constructor used to allow for obtaining a Connection in a customized manner. The org.skife.jdbi.v2.t
  • open
  • 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
  • setSQLLog
    Specify the class used to log sql statements. Will be passed to all handles created from this instan
  • 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

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • putExtra (Intent)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • CodeWhisperer alternatives
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