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


Java QueryRunner.update方法代码示例

本文整理汇总了Java中org.apache.commons.dbutils.QueryRunner.update方法的典型用法代码示例。如果您正苦于以下问题:Java QueryRunner.update方法的具体用法?Java QueryRunner.update怎么用?Java QueryRunner.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.dbutils.QueryRunner的用法示例。


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

示例1: insert

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
public static int insert(Connection dbconn, final String logContext, final int messageRef,
        final IHttpService httpService, final String clientIp, final String requestUrl, final String method,
        final byte[] reqdata) throws SQLException {
    QueryRunner runner = new QueryRunner();
    String sql =
        "insert into proxy_history(log_context, message_ref, protocol, host, port, client_ip, url, request_method, request_bytes, send_at)"
            + " values (?, ?, ?, ?, ?, ?, ?, ?, ?, now())";
    return runner.update(
        dbconn,
        sql,
        logContext,
        messageRef,
        httpService.getProtocol(),
        httpService.getHost(),
        httpService.getPort(),
        clientIp,
        requestUrl,
        method,
        reqdata);
}
 
开发者ID:SecureSkyTechnology,项目名称:burpextender-proxyhistory-webui,代码行数:21,代码来源:ProxyHistory.java

示例2: clearMySQLTestDB

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
private static void clearMySQLTestDB() throws SQLException {
  Props props = new Props();
  props.put("database.type", "mysql");
  props.put("mysql.host", "localhost");
  props.put("mysql.port", "3306");
  props.put("mysql.database", "");
  props.put("mysql.user", "root");
  props.put("mysql.password", "");
  props.put("mysql.numconnections", 10);

  DataSource datasource = DataSourceUtils.getDataSource(props);
  QueryRunner runner = new QueryRunner(datasource);
  try {
    runner.update("drop database azkabanunittest");
  } catch (SQLException e) {
  }
  runner.update("create database azkabanunittest");
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:AzkabanDatabaseSetupTest.java

示例3: createSequence

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
public void createSequence() {
    List items = db.findRecords("SHOW TABLES LIKE 'stallion_tickets'");
    if (items.size() > 0) {
        return;
    }
    QueryRunner q = db.newQuery();
    try {
        q.update("CREATE TABLE `stallion_tickets` (\n" +
                "  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n" +
                "  `ticket_name` varchar(10) DEFAULT NULL,\n" +
                "  PRIMARY KEY (`id`),\n" +
                "  UNIQUE KEY `ticket_name_unique` (`ticket_name`)\n" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
        db.execute("INSERT INTO stallion_tickets (`ticket_name`) VALUES('a')");
    } catch(Exception e) {
        Log.exception(e, "Error creating tickets table");
    }
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:19,代码来源:MySqlTickets.java

示例4: updateNextExecTime

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public void updateNextExecTime(Schedule s) throws ScheduleManagerException {
  logger.info("Update schedule " + s.getScheduleName() + " into db. ");
  Connection connection = getConnection();
  QueryRunner runner = new QueryRunner();
  try {

    runner.update(connection, UPDATE_NEXT_EXEC_TIME, s.getNextExecTime(),
        s.getProjectId(), s.getFlowName());
  } catch (SQLException e) {
    e.printStackTrace();
    logger.error(UPDATE_NEXT_EXEC_TIME + " failed.", e);
    throw new ScheduleManagerException("Update schedule "
        + s.getScheduleName() + " into db failed. ", e);
  } finally {
    DbUtils.closeQuietly(connection);
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:JdbcScheduleLoader.java

示例5: postEvent

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public boolean postEvent(Project project, EventType type, String user,
    String message) {
  QueryRunner runner = createQueryRunner();

  final String INSERT_PROJECT_EVENTS =
      "INSERT INTO project_events (project_id, event_type, event_time, username, message) values (?,?,?,?,?)";
  long updateTime = System.currentTimeMillis();
  try {
    runner.update(INSERT_PROJECT_EVENTS, project.getId(), type.getNumVal(),
        updateTime, user, message);
  } catch (SQLException e) {
    e.printStackTrace();
    return false;
  }

  return true;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:JdbcProjectLoader.java

示例6: updateDescription

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public void updateDescription(Project project, String description, String user)
    throws ProjectManagerException {
  QueryRunner runner = createQueryRunner();

  final String UPDATE_PROJECT_DESCRIPTION =
      "UPDATE projects SET description=?,modified_time=?,last_modified_by=? WHERE id=?";
  long updateTime = System.currentTimeMillis();
  try {
    runner.update(UPDATE_PROJECT_DESCRIPTION, description, updateTime, user,
        project.getId());
    project.setDescription(description);
    project.setLastModifiedTimestamp(updateTime);
    project.setLastModifiedUser(user);
  } catch (SQLException e) {
    logger.error(e);
    throw new ProjectManagerException("Error marking project "
        + project.getName() + " as inactive", e);
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:21,代码来源:JdbcProjectLoader.java

示例7: uploadFlow

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
private void uploadFlow(Connection connection, Project project, int version,
    Flow flow, EncodingType encType) throws ProjectManagerException,
    IOException {
  QueryRunner runner = new QueryRunner();
  String json = JSONUtils.toJSON(flow.toObject());
  byte[] stringData = json.getBytes("UTF-8");
  byte[] data = stringData;

  if (encType == EncodingType.GZIP) {
    data = GZIPUtils.gzipBytes(stringData);
  }

  logger.info("Flow upload " + flow.getId() + " is byte size " + data.length);
  final String INSERT_FLOW =
      "INSERT INTO project_flows (project_id, version, flow_id, modified_time, encoding_type, json) values (?,?,?,?,?,?)";
  try {
    runner.update(connection, INSERT_FLOW, project.getId(), version,
        flow.getId(), System.currentTimeMillis(), encType.getNumVal(), data);
  } catch (SQLException e) {
    throw new ProjectManagerException("Error inserting flow " + flow.getId(),
        e);
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:24,代码来源:JdbcProjectLoader.java

示例8: updateExecutableReference

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public boolean updateExecutableReference(int execId, long updateTime)
    throws ExecutorManagerException {
  final String DELETE =
      "UPDATE active_executing_flows set update_time=? WHERE exec_id=?";

  QueryRunner runner = createQueryRunner();
  int updateNum = 0;
  try {
    updateNum = runner.update(DELETE, updateTime, execId);
  } catch (SQLException e) {
    throw new ExecutorManagerException(
        "Error deleting active flow reference " + execId, e);
  }

  // Should be 1.
  return updateNum > 0;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:JdbcExecutorLoader.java

示例9: removeTrigger

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public void removeTrigger(Trigger t) throws TriggerLoaderException {
  logger.info("Removing trigger " + t.toString() + " from db.");

  QueryRunner runner = createQueryRunner();
  try {
    int removes = runner.update(REMOVE_TRIGGER, t.getTriggerId());
    if (removes == 0) {
      throw new TriggerLoaderException("No trigger has been removed.");
    }
  } catch (SQLException e) {
    logger.error(REMOVE_TRIGGER + " failed.");
    throw new TriggerLoaderException("Remove trigger " + t.toString()
        + " from db failed. ", e);
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:17,代码来源:JdbcTriggerLoader.java

示例10: clearMySQLTestDb

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
private static void clearMySQLTestDb() throws SQLException {
  Props props = new Props();

  props.put("database.type", "mysql");
  props.put("mysql.host", "localhost");
  props.put("mysql.port", "3306");
  props.put("mysql.database", "");
  props.put("mysql.user", "root");
  props.put("mysql.password", "");
  props.put("mysql.numconnections", 10);

  DataSource datasource = DataSourceUtils.getDataSource(props);
  QueryRunner runner = new QueryRunner(datasource);
  try {
    runner.update("drop database azkabanunittest");
  } catch (SQLException e) {
  }
  runner.update("create database azkabanunittest");
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:20,代码来源:AzkabanDatabaseUpdaterTest.java

示例11: updateCharset

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
public static int updateCharset(Connection dbconn, final String logContext, final int messageRef,
        final String requestCharset, final String responseCharset) throws SQLException {
    String sql =
        "update proxy_history set request_charset = ?, response_charset = ? where log_context = ? and message_ref = ?";
    QueryRunner runner = new QueryRunner();
    return runner.update(
        dbconn,
        sql,
        getCharset(requestCharset).name(),
        getCharset(responseCharset).name(),
        logContext,
        messageRef);
}
 
开发者ID:SecureSkyTechnology,项目名称:burpextender-proxyhistory-webui,代码行数:14,代码来源:ProxyHistory.java

示例12: update

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
public static int update(Connection dbconn, final String logContext, final int messageRef, final byte[] resdata,
        final int statusCode) throws SQLException {
    QueryRunner runner = new QueryRunner();
    String sql =
        "update proxy_history set response_bytes = ?, response_status_code = ?, received_at = now() "
            + " where log_context = ? and message_ref = ?";
    return runner.update(dbconn, sql, resdata, statusCode, logContext, messageRef);
}
 
开发者ID:SecureSkyTechnology,项目名称:burpextender-proxyhistory-webui,代码行数:9,代码来源:ProxyHistory.java

示例13: executeUpdate

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public void executeUpdate(String query, Connection conn) {
    QueryRunner qRunner = getQueryRunner();
    try {
        qRunner.update(conn, query);
    } catch (SQLException e) {
        throw new RTSQLException(e);
    }
}
 
开发者ID:nds842,项目名称:sql-first-mapper,代码行数:10,代码来源:DefaultNamedParamQueryExecutor.java

示例14: findPlayers

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public List<PlayerRow> findPlayers(int start, int limit) {
    QueryRunner runner = getQueryRunner();
    try(Connection connection = dataSource.getConnection()) {
        runner.update(connection, "SET @rownum := ?;", start);
        return runner.query(connection,
                "SELECT @rownum := @rownum + 1 AS rank, id, name, level, experience FROM Player WHERE isCheater=0 " +
                "ORDER BY experience DESC, LOWER(name) ASC " +
                "LIMIT ?, ?;",
                new BeanListHandler<>(PlayerRow.class), start, limit);
    } catch (SQLException e) {
        throw new GatewayError("Failed to select player rows from database", e);
    }
}
 
开发者ID:casid,项目名称:mazebert-ladder,代码行数:15,代码来源:MySqlPlayerRowGateway.java

示例15: addActiveExecutableReference

import org.apache.commons.dbutils.QueryRunner; //导入方法依赖的package包/类
@Override
public void addActiveExecutableReference(ExecutionReference reference)
    throws ExecutorManagerException {
  final String INSERT =
      "INSERT INTO active_executing_flows "
          + "(exec_id, update_time) values (?,?)";
  QueryRunner runner = createQueryRunner();

  try {
    runner.update(INSERT, reference.getExecId(), reference.getUpdateTime());
  } catch (SQLException e) {
    throw new ExecutorManagerException(
        "Error updating active flow reference " + reference.getExecId(), e);
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:16,代码来源:JdbcExecutorLoader.java


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