Exemplo n.º 1
0
  /**
   * Default implementation for query execution using a prepared statement. Subclasses may override
   * this method.
   */
  protected int execute(ExecuteContext ctx, ExecuteListener listener) throws SQLException {
    int result = 0;
    listener.executeStart(ctx);

    if (!ctx.statement().execute()) {
      result = ctx.statement().getUpdateCount();
      ctx.rows(result);
    }

    listener.executeEnd(ctx);
    return result;
  }
Exemplo n.º 2
0
  /**
   * Default implementation for query execution using a prepared statement. Subclasses may override
   * this method.
   */
  protected int execute(ExecuteContext ctx, ExecuteListener listener) throws SQLException {
    int result = 0;
    PreparedStatement stmt = ctx.statement();

    try {
      listener.executeStart(ctx);

      // [#1829] Statement.execute() is preferred over Statement.executeUpdate(), as
      // we might be executing plain SQL and returning results.
      if (!stmt.execute()) {
        result = stmt.getUpdateCount();
        ctx.rows(result);
      }

      listener.executeEnd(ctx);
      return result;
    }

    // [#3011] [#3054] Consume additional exceptions if there are any
    catch (SQLException e) {
      consumeExceptions(ctx.configuration(), stmt, e);
      throw e;
    }
  }