当前位置: 首页>>代码示例>>Java>>正文


Java JdbcExecutor类代码示例

本文整理汇总了Java中com.google.gwtorm.jdbc.JdbcExecutor的典型用法代码示例。如果您正苦于以下问题:Java JdbcExecutor类的具体用法?Java JdbcExecutor怎么用?Java JdbcExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JdbcExecutor类属于com.google.gwtorm.jdbc包,在下文中一共展示了JdbcExecutor类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: migrateData

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
  conn = ((JdbcSchema) db).getConnection();
  dialect = ((JdbcSchema) db).getDialect();
  Map<String, PrimaryKey> corrections = findPKUpdates();
  if (corrections.isEmpty()) {
    return;
  }

  ui.message("Wrong Primary Key Column Order Detected");
  ui.message("The following tables are affected:");
  ui.message(Joiner.on(", ").join(corrections.keySet()));
  ui.message("fixing primary keys...");
  try (JdbcExecutor executor = new JdbcExecutor(conn)) {
    for (Map.Entry<String, PrimaryKey> c : corrections.entrySet()) {
      ui.message(String.format("  table: %s ... ", c.getKey()));
      recreatePK(executor, c.getKey(), c.getValue(), ui);
      ui.message("done");
    }
    ui.message("done");
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:Schema_101.java

示例2: upgradeFrom

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Runs check on the prior schema version, and then upgrades. */
private void upgradeFrom(UpdateUI ui, CurrentSchemaVersion curr, CiDb db)
    throws OrmException, SQLException {
  List<SchemaVersion> pending = pending(curr.versionNbr);
  updateSchema(pending, ui, db);
  migrateData(pending, ui, curr, db);

  JdbcSchema s = (JdbcSchema) db;
  final List<String> pruneList = Lists.newArrayList();
  s.pruneSchema(new StatementExecutor() {
    @Override
    public void execute(String sql) {
      pruneList.add(sql);
    }

    @Override
    public void close() {
      // Do nothing.
    }
  });

  try (JdbcExecutor e = new JdbcExecutor(s)) {
    if (!pruneList.isEmpty()) {
      ui.pruneSchema(e, pruneList);
    }
  }
}
 
开发者ID:davido,项目名称:gerrit-ci-plugin,代码行数:28,代码来源:SchemaVersion.java

示例3: updateSchema

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
private void updateSchema(List<SchemaVersion> pending, UpdateUI ui,
    CiDb db) throws OrmException, SQLException {
  for (SchemaVersion v : pending) {
    ui.message(String.format("Upgrading schema to %d ...", v.getVersionNbr()));
    v.preUpdateSchema(db);
  }

  JdbcSchema s = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(s)) {
    s.updateSchema(e);
  }
}
 
开发者ID:davido,项目名称:gerrit-ci-plugin,代码行数:13,代码来源:SchemaVersion.java

示例4: renameTable

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Rename an existing table. */
protected static void renameTable(ReviewDb db, String from, String to)
    throws OrmException {
  JdbcSchema s = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(s)) {
    s.renameTable(e, from, to);
  }
}
 
开发者ID:davido,项目名称:gerrit-ci-plugin,代码行数:9,代码来源:SchemaVersion.java

示例5: renameColumn

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Rename an existing column. */
protected static void renameColumn(ReviewDb db, String table, String from, String to)
    throws OrmException {
  JdbcSchema s = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(s)) {
    s.renameField(e, table, from, to);
  }
}
 
开发者ID:davido,项目名称:gerrit-ci-plugin,代码行数:9,代码来源:SchemaVersion.java

示例6: create

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
public void create(ReviewDb db) throws OrmException, IOException, ConfigInvalidException {
  final JdbcSchema jdbc = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(jdbc)) {
    jdbc.updateSchema(e);
  }

  final CurrentSchemaVersion sVer = CurrentSchemaVersion.create();
  sVer.versionNbr = SchemaVersion.getBinaryVersion();
  db.schemaVersion().insert(Collections.singleton(sVer));

  GroupReference admins = createGroupReference("Administrators");
  GroupReference batchUsers = createGroupReference("Non-Interactive Users");

  initSystemConfig(db);
  allProjectsCreator.setAdministrators(admins).setBatchUsers(batchUsers).create();
  // We have to create the All-Users repository before we can use it to store the groups in it.
  allUsersCreator.setAdministrators(admins).create();

  // Don't rely on injection to construct Sequences, as it requires ReviewDb.
  Sequences seqs =
      new Sequences(
          config,
          () -> db,
          migration,
          repoManager,
          GitReferenceUpdated.DISABLED,
          allProjectsName,
          allUsersName,
          metricMaker);
  try (Repository repository = repoManager.openRepository(allUsersName)) {
    createAdminsGroup(db, seqs, repository, admins);
    createBatchUsersGroup(db, seqs, repository, batchUsers, admins);
  }

  dataSourceType.getIndexScript().run(db);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:37,代码来源:SchemaCreator.java

示例7: upgradeFrom

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Runs check on the prior schema version, and then upgrades. */
private void upgradeFrom(UpdateUI ui, CurrentSchemaVersion curr, ReviewDb db)
    throws OrmException, SQLException {
  List<SchemaVersion> pending = pending(curr.versionNbr);
  updateSchema(pending, ui, db);
  migrateData(pending, ui, curr, db);

  JdbcSchema s = (JdbcSchema) db;
  final List<String> pruneList = new ArrayList<>();
  s.pruneSchema(
      new StatementExecutor() {
        @Override
        public void execute(String sql) {
          pruneList.add(sql);
        }

        @Override
        public void close() {
          // Do nothing.
        }
      });

  try (JdbcExecutor e = new JdbcExecutor(s)) {
    if (!pruneList.isEmpty()) {
      ui.pruneSchema(e, pruneList);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:SchemaVersion.java

示例8: updateSchema

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
private void updateSchema(List<SchemaVersion> pending, UpdateUI ui, ReviewDb db)
    throws OrmException, SQLException {
  for (SchemaVersion v : pending) {
    ui.message(String.format("Upgrading schema to %d ...", v.getVersionNbr()));
    v.preUpdateSchema(db);
  }

  JdbcSchema s = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(s)) {
    s.updateSchema(e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:13,代码来源:SchemaVersion.java

示例9: renameTable

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Rename an existing table. */
protected static void renameTable(ReviewDb db, String from, String to) throws OrmException {
  JdbcSchema s = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(s)) {
    s.renameTable(e, from, to);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:SchemaVersion.java

示例10: renameColumn

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Rename an existing column. */
protected static void renameColumn(ReviewDb db, String table, String from, String to)
    throws OrmException {
  JdbcSchema s = (JdbcSchema) db;
  try (JdbcExecutor e = new JdbcExecutor(s)) {
    s.renameColumn(e, table, from, to);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:SchemaVersion.java

示例11: newExecutor

import com.google.gwtorm.jdbc.JdbcExecutor; //导入依赖的package包/类
/** Open a new statement executor. */
protected static JdbcExecutor newExecutor(ReviewDb db) throws OrmException {
  return new JdbcExecutor(((JdbcSchema) db).getConnection());
}
 
开发者ID:davido,项目名称:gerrit-ci-plugin,代码行数:5,代码来源:SchemaVersion.java


注:本文中的com.google.gwtorm.jdbc.JdbcExecutor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。