PreparedBatch.bind
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.jdbi.v3.core.statement.PreparedBatch.bind(Showing top 15 results out of 315)

origin: prestodb/presto

Type type = columns.get(column).getType();
if (BOOLEAN.equals(type)) {
  batch.bind(column, cursor.getBoolean(column));
  batch.bind(column, cursor.getLong(column));
  batch.bind(column, (int) cursor.getLong(column));
  batch.bind(column, cursor.getDouble(column));
  batch.bind(column, cursor.getSlice(column).toStringUtf8());
  batch.bind(column, new Date(localMillis));
origin: jdbi/jdbi

@Test
public void testBindBatch() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  b.bind("id", 1).bind("name", "Eric").add();
  b.bind("id", 2).bind("name", "Brian").add();
  b.bind("id", 3).bind("name", "Keith").add();
  b.execute();
  List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).hasSize(3);
  assertThat(r.get(2).getName()).isEqualTo("Keith");
}
origin: jdbi/jdbi

@Test
public void testBigishBatch() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  int count = 100;
  for (int i = 0; i < count; ++i)
  {
    b.bind("id", i).bind("name", "A Name").add();
  }
  b.execute();
  int row_count = h.createQuery("select count(id) from something").mapTo(int.class).findOnly();
  assertThat(row_count).isEqualTo(count);
}
origin: jdbi/jdbi

/**
 * Bind arguments positionally, add the binding as a saved batch, and
 * then clear the current binding.
 * @param args the positional arguments to bind
 * @return this
 */
public PreparedBatch add(Object... args)
{
  for(int i = 0; i < args.length; i++) {
    bind(i, args[i]);
  }
  add();
  return this;
}
origin: jdbi/jdbi

@Test
public void testOnPreparedBatch() throws Exception
{
  Handle h = dbRule.getSharedHandle();
  PreparedBatch batch = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  batch.registerArgument(new NameAF());
  batch.bind("id", 1).bind("name", new Name("Brian", "McCallister")).add();
  batch.bind("id", 2).bind("name", new Name("Henning", "S")).add();
  batch.execute();
  List<String> rs = h.createQuery("select name from something order by id")
            .mapTo(String.class)
            .list();
  assertThat(rs.get(0)).isEqualTo("Brian McCallister");
  assertThat(rs.get(1)).isEqualTo("Henning S");
}
origin: jdbi/jdbi

@Test
public void testPositionalBinding() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (?, ?)");
  b.bind(0, 0).bind(1, "Keith").add().execute();
  List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).extracting(Something::getName).containsExactly("Keith");
}
origin: org.jdbi/jdbi3-core

@Test
public void testMultipleExecuteBind()
{
  final PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  b.bind("id", 1).bind("name", "Eric").add();
  b.bind("id", 2).bind("name", "Brian").add();
  b.execute();
  // bindings should be cleared after execute()
  b.bind("id", 3).bind("name", "Keith").add();
  b.execute();
  final List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).hasSize(3);
  assertThat(r.get(0)).extracting(Something::getId, Something::getName).containsSequence(1, "Eric");
  assertThat(r.get(1)).extracting(Something::getId, Something::getName).containsSequence(2, "Brian");
  assertThat(r.get(2)).extracting(Something::getId, Something::getName).containsSequence(3, "Keith");
}
origin: jdbi/jdbi

@Test
public void testForgotFinalAdd() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  b.bind("id", 1);
  b.bind("name", "Jeff");
  b.add();
  b.bind("id", 2);
  b.bind("name", "Tom");
  // forgot to add() here but we fix it up
  b.execute();
  assertThat(h.createQuery("select name from something order by id").mapTo(String.class).list())
      .containsExactly("Jeff", "Tom");
}
origin: jdbi/jdbi

@Test
public void testMixedModeBatch() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  Map<String, Object> one = ImmutableMap.of("id", 0);
  b.bind("name", "Keith").add(one);
  b.execute();
  List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).extracting(Something::getName).containsExactly("Keith");
}
origin: org.jdbi/jdbi3-core

@Test
public void testBindBatch() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  b.bind("id", 1).bind("name", "Eric").add();
  b.bind("id", 2).bind("name", "Brian").add();
  b.bind("id", 3).bind("name", "Keith").add();
  b.execute();
  List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).hasSize(3);
  assertThat(r.get(2).getName()).isEqualTo("Keith");
}
origin: org.jdbi/jdbi3-core

@Test
public void testMixedModeBatch() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  Map<String, Object> one = ImmutableMap.of("id", 0);
  b.bind("name", "Keith").add(one);
  b.execute();
  List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).extracting(Something::getName).containsExactly("Keith");
}
origin: org.jdbi/jdbi3-core

@Test
public void testPositionalBinding() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (?, ?)");
  b.bind(0, 0).bind(1, "Keith").add().execute();
  List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
  assertThat(r).extracting(Something::getName).containsExactly("Keith");
}
origin: org.jdbi/jdbi3-core

@Test
public void testBigishBatch() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  int count = 100;
  for (int i = 0; i < count; ++i)
  {
    b.bind("id", i).bind("name", "A Name").add();
  }
  b.execute();
  int row_count = h.createQuery("select count(id) from something").mapTo(int.class).findOnly();
  assertThat(row_count).isEqualTo(count);
}
origin: org.jdbi/jdbi3-core

@Test
public void testForgotFinalAdd() throws Exception
{
  PreparedBatch b = h.prepareBatch("insert into something (id, name) values (:id, :name)");
  b.bind("id", 1);
  b.bind("name", "Jeff");
  b.add();
  b.bind("id", 2);
  b.bind("name", "Tom");
  // forgot to add() here but we fix it up
  b.execute();
  assertThat(h.createQuery("select name from something order by id").mapTo(String.class).list())
      .containsExactly("Jeff", "Tom");
}
origin: org.jdbi/jdbi3-core

/**
 * Bind arguments positionally, add the binding as a saved batch, and
 * then clear the current binding.
 * @param args the positional arguments to bind
 * @return this
 */
public PreparedBatch add(Object... args)
{
  for(int i = 0; i < args.length; i++) {
    bind(i, args[i]);
  }
  add();
  return this;
}
org.jdbi.v3.core.statementPreparedBatchbind

Popular methods of PreparedBatch

  • add
    Bind arguments positionally, add the binding as a saved batch, and then clear the current binding.
  • execute
    Executes the batch, returning the result obtained from the given ResultProducer.
  • <init>
  • addCleanable
  • afterExecution
  • beforeBinding
  • beforeExecution
  • bindBean
  • bindFields
  • bindMap
  • close
  • executeAndReturnGeneratedKeys
  • close,
  • executeAndReturnGeneratedKeys,
  • getBinding,
  • getConfig,
  • getContext,
  • getHandle,
  • getSql,
  • internalBatchExecute,
  • registerArgument

Popular classes and methods

  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement.A servlet is a small Java program that runs within
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)