本文整理汇总了Java中org.skife.jdbi.v2.PreparedBatch类的典型用法代码示例。如果您正苦于以下问题:Java PreparedBatch类的具体用法?Java PreparedBatch怎么用?Java PreparedBatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PreparedBatch类属于org.skife.jdbi.v2包,在下文中一共展示了PreparedBatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createSetConsumer
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
public Consumer<JsonRecord> createSetConsumer() {
return r -> {
PreparedBatch insert = getInsertBatch();
insert.bind("path", r.getPath())
.bind("value", r.getValue())
.bind("kind", r.getKind())
.bind("idx", r.getIndex())
.add();
batchSize += r.getPath().length() + r.getValue().length();
if (batchSize > 512 * 1024) { // Write the batch once we have enough data.
insert.execute();
batchSize = 0;
}
};
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:SqlJsonDB.java
示例2: loadAlleleCodes
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void loadAlleleCodes(Iterator<AlleleCodeRow> rowIter, boolean reload) {
try (Handle handle = dbi.open()) {
if (reload) {
handle.createStatement("delete from allele_code").execute();
}
PreparedBatch batch = handle.prepareBatch("insert or ignore into allele_code(allele_code, allele, family_included) values (?, ?, ?)");
long i = 0;
while (rowIter.hasNext()) {
AlleleCodeRow g = rowIter.next();
batch.add(g.getCode(), g.getAllele(), g.isGeneric());
if (0 == ++i % 10000L) {
logger.debug("committing " + i + " rows...");
batch.execute();
}
}
if (0 != i % 1000L) batch.execute();
}
}
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:20,代码来源:DbiManagerImpl.java
示例3: storeAll
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void storeAll(final Map<Long, String> items) {
log.info(String.format("storing all within table %s", tableName));
dbi.inTransaction(new TransactionCallback<Integer>() {
@Override
public Integer inTransaction(Handle h, TransactionStatus ts)
throws Exception {
PreparedBatch pb = h.prepareBatch(String.format("append into %s (id, value) values (:id, :value)", tableName));
for (Map.Entry<Long, String> entry : items.entrySet()){
log.info("store " + entry.getKey() + ", value = " + entry.getValue());
pb.add().bind("id", entry.getKey()).bind("value", entry.getValue());
}
return pb.execute().length;
}
}) ;
}
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:17,代码来源:HzStringQueueStore.java
示例4: suspendIntoFlatVertexTable
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
public void suspendIntoFlatVertexTable(Long sessId, State state, String table, Set<AmberVertex> set) {
Set<String> fields = getFields(set, state);
String sql = String.format("INSERT INTO %s (s_id, state, id, txn_start, txn_end %s) values (:s_id, :state, :id, :txn_start, :txn_end %s)",
table,
StringUtils.join(format(fields, ", %s"), ' '),
StringUtils.join(format(fields, ", :%s"), ' '));
Handle h = getHandle();
PreparedBatch preparedBatch = h.prepareBatch(sql);
for (AmberVertex v: set) {
PreparedBatchPart preparedBatchPart = preparedBatch.add();
preparedBatchPart.bind("s_id", sessId);
preparedBatchPart.bind("state", state.name());
preparedBatchPart.bind("id", v.getId());
preparedBatchPart.bind("txn_start", v.getTxnStart());
preparedBatchPart.bind("txn_end", v.getTxnEnd());
if (state != DEL) {
for (String field: fields) {
bindField(v, preparedBatchPart, field);
}
}
}
preparedBatch.execute();
}
开发者ID:nla,项目名称:amberdb,代码行数:25,代码来源:AmberDao.java
示例5: suspendIntoFlatEdgeTable
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
public void suspendIntoFlatEdgeTable(Long sessId, State state, Set<AmberEdge> set) {
String sql = "INSERT INTO sess_flatedge (s_id, state, id, txn_start, txn_end, v_out, v_in, edge_order, label) values (:s_id, :state, :id, :txn_start, :txn_end, :v_out, :v_in, :edge_order, :label)";
Handle h = getHandle();
PreparedBatch preparedBatch = h.prepareBatch(sql);
for (AmberEdge v: set) {
PreparedBatchPart preparedBatchPart = preparedBatch.add();
preparedBatchPart.bind("s_id", sessId);
preparedBatchPart.bind("state", state.name());
preparedBatchPart.bind("id", v.getId());
preparedBatchPart.bind("txn_start", v.getTxnStart());
preparedBatchPart.bind("txn_end", v.getTxnEnd());
preparedBatchPart.bind("v_out", v.getOutId());
preparedBatchPart.bind("v_in", v.getInId());
preparedBatchPart.bind("edge_order", v.getOrder());
preparedBatchPart.bind("label", v.getLabel());
}
preparedBatch.execute();
}
开发者ID:nla,项目名称:amberdb,代码行数:21,代码来源:AmberDao.java
示例6: deleteDepartments
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void deleteDepartments(List<Department> departmentsToDelete) {
try (Handle h = dbi.open()) {
PreparedBatch preparedBatch = h.prepareBatch("DELETE FROM department WHERE pid = :pid");
for (Department department : departmentsToDelete) {
preparedBatch.bind("pid", department.getPid()).add();
}
preparedBatch.execute();
}
}
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:13,代码来源:JDBIDataRepositoryImpl.java
示例7: updateDepartments
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void updateDepartments(List<Department> departmentsToUpdate) {
try (Handle h = dbi.open()) {
PreparedBatch preparedBatch = h.prepareBatch("UPDATE department SET company_pid = :company_pid, name = :name WHERE pid = :pid");
for (Department department : departmentsToUpdate) {
preparedBatch
.bind("company_pid", department.getCompanyPid())
.bind("name", department.getName())
.bind("pid", department.getPid())
.add();
}
preparedBatch.execute();
}
}
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:15,代码来源:JDBIDataRepositoryImpl.java
示例8: insertDepartments
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void insertDepartments(List<Department> departmentsToInsert) {
try (Handle h = dbi.open()) {
PreparedBatch preparedBatch = h.prepareBatch("INSERT INTO department (company_pid, name) VALUES (:company_pid, :name)");
for (Department department : departmentsToInsert) {
preparedBatch
.bind("company_pid", department.getCompanyPid())
.bind("name", department.getName())
.add();
}
preparedBatch.execute();
}
}
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:14,代码来源:JDBIDataRepositoryImpl.java
示例9: insertProjects
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public List<Integer> insertProjects(List<Project> projects) {
try (Handle h = dbi.open()) {
PreparedBatch preparedBatch = h.prepareBatch("INSERT INTO project (name, datestarted) VALUES (:name, :datestarted)");
for (Project project : projects) {
preparedBatch
.bind("name", project.getName())
.bind("datestarted", project.getDate())
.add();
}
return preparedBatch.executeAndGenerateKeys(IntegerColumnMapper.WRAPPER).list();
}
}
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:14,代码来源:JDBIDataRepositoryImpl.java
示例10: createSetConsumer
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
public Consumer<JsonRecord> createSetConsumer() {
return r -> {
PreparedBatch insert = getInsertBatch();
insert.bind("path", r.getPath())
.bind("value", r.getValue())
.bind("kind", r.getKind())
.add();
batchSize += r.getPath().length() + r.getValue().length();
if (batchSize > 512 * 1024) { // Write the batch once we have enough data.
insert.execute();
batchSize = 0;
}
};
}
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:16,代码来源:SqlJsonDB.java
示例11: loadPGroups
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void loadPGroups(Iterator<GroupRow<String>> rowIter, boolean reload) {
try (Handle handle = dbi.open()) {
if (reload) {
handle.createStatement("delete from hla_p_group").execute();
}
PreparedBatch batch = handle.prepareBatch("insert or ignore into hla_p_group(p_group, locus, allele) values (?, ?, ?)");
rowIter.forEachRemaining(g -> batch.add(g.getGroup(), g.getLocus(), g.getAllele()));
batch.execute();
}
}
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:15,代码来源:DbiManagerImpl.java
示例12: loadGGroups
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void loadGGroups(Iterator<GroupRow<String>> rowIter, boolean reload) {
try (Handle handle = dbi.open()) {
if (reload) {
handle.createStatement("delete from hla_g_group").execute();
}
PreparedBatch batch = handle.prepareBatch("insert or ignore into hla_g_group(g_group, locus, allele) values (?, ?, ?)");
rowIter.forEachRemaining(g -> batch.add(g.getGroup(), g.getLocus(), g.getAllele()));
batch.execute();
}
}
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:15,代码来源:DbiManagerImpl.java
示例13: loadAlleles
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void loadAlleles(Iterator<AlleleRow> rowIter, boolean reload) {
try (Handle handle = dbi.open()) {
if (reload) {
handle.createStatement("delete from hla_allele").execute();
}
PreparedBatch batch = handle.prepareBatch("insert or ignore into hla_allele(locus, allele) values (?, ?)");
rowIter.forEachRemaining(g -> batch.add(g.getLocus(), g.getAllele()));
batch.execute();
}
}
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:15,代码来源:DbiManagerImpl.java
示例14: loadImmuneGroups
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void loadImmuneGroups(Iterator<GroupRow<Integer>> rowIter, boolean reload) {
try (Handle handle = dbi.open()) {
if (reload) {
handle.createStatement("delete from allele_group").execute();
}
PreparedBatch batch = handle.prepareBatch("insert or ignore into allele_group(locus, allele, immune_group) values (?, ?, ?)");
rowIter.forEachRemaining(g -> batch.add(g.getLocus(), g.getAllele(), g.getGroup()));
batch.execute();
}
}
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:15,代码来源:DbiManagerImpl.java
示例15: loadCsv
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
public static void loadCsv(Connection conn, String sql, String csvResource) throws Exception {
log.debug("csvResource: " + csvResource);
URL csvUrl = DbUtil.class.getClassLoader().getResource(csvResource);
log.debug("csvUrl: " + csvUrl);
try (Handle handle = DBI.open(conn)) {
PreparedBatch batch = handle.prepareBatch(sql);
Iterator<Object[]> it = readCsv(csvUrl);
while (it.hasNext()) {
Object[] row = it.next();
log.trace("row: " + Arrays.toString(row));
batch.add(row);
}
batch.execute();
}
}
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:16,代码来源:DbUtil.java
示例16: putAll
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void putAll(@Nullable Map<? extends K, ? extends V> map) {
final PreparedBatch batch = handle.prepareBatch(String.format("REPLACE INTO %1$s (row_field, column_field, value_field) VALUES (:row_field, :column_field, :value_field)", tableName));
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
final SelectionMap valueMap = selectionMapFactory.get(entry.getKey());
batch.add()
.bindFromMap(selectionMap.asMap())
.bindFromMap(valueMap.asMap())
.bind("value_field", entry.getValue());
}
batch.execute();
}
开发者ID:reines,项目名称:db-table,代码行数:15,代码来源:DbMap.java
示例17: putAll
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void putAll(@Nullable Table<? extends byte[], ? extends byte[], ? extends byte[]> table) {
final PreparedBatch batch = handle.prepareBatch(String.format("REPLACE INTO %s VALUES (:row_field, :column_field, :value_field)", tableName));
for (Table.Cell<? extends byte[], ? extends byte[], ? extends byte[]> cell : table.cellSet()) {
batch.add()
.bind("row_field", cell.getRowKey())
.bind("column_field", cell.getColumnKey())
.bind("value_field", cell.getValue());
}
batch.execute();
}
开发者ID:reines,项目名称:db-table,代码行数:14,代码来源:DbTable.java
示例18: deleteAll
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void deleteAll(final Collection<Long> ids) {
log.info(String.format("deleting all within table %s", tableName));
dbi.inTransaction(new TransactionCallback<Integer>() {
@Override
public Integer inTransaction(Handle h, TransactionStatus ts)
throws Exception {
PreparedBatch pb = h.prepareBatch(String.format("delete from %s where id = :id", tableName));
for (Long id: ids){
pb.add().bind("id", id);
}
return pb.execute().length;
}
}) ;
}
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:16,代码来源:HzStringQueueStore.java
示例19: deleteAll
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
public void deleteAll(final Collection<UUID> ids) {
log.debug("deleting {} rows within table {}", ids.size(), tableName);
dbi.inTransaction(new TransactionCallback<Integer>() {
@Override
public Integer inTransaction(Handle h, TransactionStatus ts)
throws Exception {
PreparedBatch pb = h.prepareBatch(String.format("delete from %s where id = :id", tableName));
for (UUID id: ids){
pb.add().bind("id", id.toString());
}
return pb.execute().length;
}
}) ;
}
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:16,代码来源:HzStringMapStore.java
示例20: before
import org.skife.jdbi.v2.PreparedBatch; //导入依赖的package包/类
@Override
protected void before(final Handle handle)
{
handle.execute("create table something ( id int primary key, name varchar(255) )");
PreparedBatch batch = handle.prepareBatch("insert into something (id, name) values (:id, :name)");
batch.bind("id", 1).bind("name", "Gene").add();
batch.bind("id", 2).bind("name", "Brian").add();
batch.execute();
}
开发者ID:groupon,项目名称:mysql-junit4,代码行数:10,代码来源:MySQLRuleExample.java
注:本文中的org.skife.jdbi.v2.PreparedBatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论