org.sql2o.Query.executeUpdate()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(258)

本文整理了Java中org.sql2o.Query.executeUpdate方法的一些代码示例,展示了Query.executeUpdate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.executeUpdate方法的具体详情如下:
包路径:org.sql2o.Query
类名称:Query
方法名:executeUpdate

Query.executeUpdate介绍

暂无

代码示例

代码示例来源:origin: runelite/runelite

public void associateArchiveToIndex(Connection con, ArchiveEntry archive, IndexEntry index)
{
  if (associateArchive == null)
  {
    associateArchive = con.createQuery("insert into index_archive (`index`, archive) values (:index, :archive)");
  }
  associateArchive
    .addParameter("index", index.getId())
    .addParameter("archive", archive.getId())
    .executeUpdate();
}

代码示例来源:origin: runelite/runelite

public void associateFileToArchive(Connection con, ArchiveEntry archive, int fileId, int nameHash)
  {
    if (associateFile == null)
    {
      associateFile = con.createQuery("insert into file (archive, fileId, nameHash) values (:archive, :fileId, :nameHash)");
    }
    associateFile
      .addParameter("archive", archive.getId())
      .addParameter("fileId", fileId)
      .addParameter("nameHash", nameHash)
      .executeUpdate();
  }
}

代码示例来源:origin: runelite/runelite

public CacheEntry createCache(Connection con, int revision, Instant date)
{
  int cacheId = con.createQuery("insert into cache (revision, date) values (:revision, :date)")
    .addParameter("revision", revision)
    .addParameter("date", date)
    .executeUpdate()
    .getKey(int.class);
  CacheEntry entry = new CacheEntry();
  entry.setId(cacheId);
  entry.setRevision(revision);
  entry.setDate(date);
  return entry;
}

代码示例来源:origin: runelite/runelite

public IndexEntry createIndex(Connection con, CacheEntry cache, int indexId, int crc, int revision)
{
  int id = con.createQuery("insert into `index` (cache, indexId, crc, revision) values (:cache, :indexId, :crc, :revision)")
    .addParameter("cache", cache.getId())
    .addParameter("indexId", indexId)
    .addParameter("crc", crc)
    .addParameter("revision", revision)
    .executeUpdate()
    .getKey(int.class);
  IndexEntry entry = new IndexEntry();
  entry.setId(id);
  entry.setIndexId(indexId);
  entry.setCrc(crc);
  entry.setRevision(revision);
  return entry;
}

代码示例来源:origin: runelite/runelite

public ArchiveEntry createArchive(Connection con, IndexEntry index,
  int archiveId, int nameHash, int crc, int revision, byte[] hash)
{
  if (insertArchive == null)
  {
    insertArchive = con.createQuery("insert into archive (archiveId, nameHash, crc, revision, hash) values "
      + "(:archiveId, :nameHash, :crc, :revision, :hash)");
  }
  int id = insertArchive
    .addParameter("archiveId", archiveId)
    .addParameter("nameHash", nameHash)
    .addParameter("crc", crc)
    .addParameter("revision", revision)
    .addParameter("hash", hash)
    .executeUpdate()
    .getKey(int.class);
  ArchiveEntry entry = new ArchiveEntry();
  entry.setId(id);
  entry.setArchiveId(archiveId);
  entry.setNameHash(nameHash);
  entry.setCrc(crc);
  entry.setRevision(revision);
  entry.setHash(hash);
  return entry;
}

代码示例来源:origin: iNPUTmice/caas

public static boolean removeServer(Connection connection, Server server) {
  String query = "delete from servers where domain=:domain";
  connection.createQuery(query)
      .bind(server)
      .executeUpdate();
  return true;
}

代码示例来源:origin: iNPUTmice/caas

public static boolean addCredential(Connection connection, Credential credential) {
  String query = "insert into credentials(domain,jid,password) values(:domain,:jid,:password)";
  connection.createQuery(query).bind(credential).executeUpdate();
  return true;
}

代码示例来源:origin: iNPUTmice/caas

public static boolean updateServer(Connection connection, Server newServer) {
  String query = "update servers set" +
      " domain=:domain," +
      " listed=:listed," +
      " software_name=:softwareName," +
      " software_version=:softwareVersion" +
      " where domain=:domain";
  connection.createQuery(query)
      .bind(newServer)
      .executeUpdate();
  return true;
}

代码示例来源:origin: iNPUTmice/caas

public static boolean addSubscriber(Connection connection, Subscriber subscriber) {
  connection.createQuery("insert into subscribers(domain,email,unsubscribeCode) " +
      "values(:domain,:email,:unsubscribeCode)")
      .bind(subscriber)
      .executeUpdate();
  return true;
}

代码示例来源:origin: 100cm/thunder

public  static void delete(int id ,Class<?> c){
   String name = Util.getclassName(c).toLowerCase();
   String sql = "delete from "+ name + " where id = '" + id+"'";
  Logger logger = LogManager.getLogger(ActiveRecordBase.class);
  logger.info(Constant.LOG_AC_NAME+" execute sql " + sql);
   DB.sql2o.beginTransaction().createQuery(sql).executeUpdate().commit();
}
public static  void delete_by_sql(String sql){

代码示例来源:origin: sparktutorials/BlogService_SparkExample

@Override
public void deletePost(UUID uuid) {
  try (Connection conn = sql2o.open()) {
    conn.createQuery("delete from posts where post_uuid=:post_uuid")
        .addParameter("post_uuid", uuid)
        .executeUpdate();
  }
}

代码示例来源:origin: iNPUTmice/caas

public static boolean setListed(Connection connection, String domain, boolean listedServer) {
  String query = "update servers set" +
      " listed=:listed" +
      " where domain=:domain";
  connection.createQuery(query)
      .addParameter("listed", listedServer)
      .addParameter("domain", domain)
      .executeUpdate();
  return true;
}

代码示例来源:origin: 100cm/thunder

public void update(Object o) {
  this.customSql.setUpdate(o);
  System.out.print(buildSql(this.customSql));
  connection.createQuery(buildSql(this.customSql)).executeUpdate();
}

代码示例来源:origin: 100cm/thunder

public static  void delete_by_sql(String sql){
  Logger logger = LogManager.getLogger(ActiveRecordBase.class);
  logger.info(Constant.LOG_AC_NAME+" execute sql " + sql);
  DB.sql2o.beginTransaction().createQuery(sql).executeUpdate().commit();
}

代码示例来源:origin: 100cm/thunder

public static void update_by_sql(String sql){
  Logger logger = LogManager.getLogger(ActiveRecordBase.class);
  logger.info(Constant.LOG_AC_NAME+" execute sql " + sql);
  DB.sql2o.beginTransaction().createQuery(sql).executeUpdate().commit();
}

代码示例来源:origin: 100cm/thunder

public static Object insert_by_sql(String sql){
  Logger logger = LogManager.getLogger(ActiveRecordBase.class);
  logger.info(Constant.LOG_AC_NAME+" execute sql " + sql);
  return DB.sql2o.beginTransaction().createQuery(sql).executeUpdate().getKey();
}

代码示例来源:origin: iNPUTmice/caas

private static void addIteration(Connection connection, int iterationNumber, Instant beginTime, Instant endTime) {
  String query = "insert into periodic_test_iterations(iteration_number,begin_time,end_time) " +
      "values(:number,:begin,:end)";
  //Insert periodic result iteration details
    connection.createQuery(query)
        .addParameter("number", iterationNumber)
        .addParameter("begin", beginTime)
        .addParameter("end", endTime)
        .executeUpdate();
}

代码示例来源:origin: aalmiray/javatrove

@Override
public void delete(final Todo todo) {
  sql2oHandler.withSql2o(sql2o -> {
    sql2o.withConnection((connection, argument) -> {
      connection.createQuery("DELETE FROM todos WHERE id = :id")
        .addParameter("id", todo.getId())
        .executeUpdate();
    });
    return todo;
  });
}

代码示例来源:origin: iNPUTmice/caas

public static Subscriber removeSubscriber(Connection connection, String unsubscribeCode) {
  Subscriber subscriber = connection.createQuery(
      "select email,domain,unsubscribeCode from subscribers " +
          "where unsubscribeCode=:unsubscribeCode")
      .addParameter("unsubscribeCode", unsubscribeCode)
      .executeAndFetchFirst(Subscriber.class);
  connection.createQuery("delete from subscribers " +
      "where unsubscribeCode=:unsubscribeCode")
      .addParameter("unsubscribeCode", unsubscribeCode)
      .executeUpdate();
  return subscriber;
}

代码示例来源:origin: sparktutorials/BlogService_SparkExample

@Override
public void updatePost(Post post) {
  try (Connection conn = sql2o.open()) {
    conn.createQuery("update posts set title=:title, content=:content where post_uuid=:post_uuid")
        .addParameter("post_uuid", post.getPost_uuid())
        .addParameter("title", post.getTitle())
        .addParameter("content", post.getContent())
        .executeUpdate();
  }
}

相关文章