Evaluate an ad-hoc predicate on the list of provided objects.
Note {@link #evaluate(Object[])} is preferable as it only does validation of the expression once.
@throws SQLException
433969
public boolean evaluate(List<Object> objects, String sql) throws SQLException {
		synchronized (this) {
			String actualSql = sql == null ? this.sql : sql;
			PreparedStatement actualStmnt = null;
			try {
				actualStmnt = sql == null ? this.stmnt : prepareStatement(sql);

				this.objects = objects;
				actualStmnt.execute();
				ResultSet rs = actualStmnt.getResultSet();
				if (!rs.next()) {
					throw new IllegalArgumentException("Expected at least one returned row. SQL evaluated: " + actualSql);
				}
				boolean result = true;
				do {
					result &= rs.getBoolean(1);
				} while (rs.next());
				return result;
			} finally {
				if (sql != null && actualStmnt != null) {
					actualStmnt.close();
				}
			}
		}
	}
292316
private void executeQueryPrologue(ServerPrepareResult serverPrepareResult) throws SQLException {
    executing = true;
    if (closed) {
      throw new SQLException("execute() is called on closed statement");
    }
    protocol
        .prologProxy(serverPrepareResult, maxRows, protocol.getProxy() != null, connection, this);

  }
1053602
@Override
	public final ResultSet executeQuery() throws SQLException {
		Split split = prepare();
		try {
			return new SimonResultSet(stmt.executeQuery(), this, prefix, split.getStopwatch().getName());
		} finally {
			finish(split);
		}
	}
1002695
public static SQLException chainException(android.database.SQLException sqlException) {
        if ( sqlThrowable < 0 || sqlThrowable >= 9 ) {
            try {
                sqlThrowable = 9;
                //return new SQLException (sqlException);
                // creating by reflection is significantly slower, but since Exceptions should be unusual
                // this should not be a performance issue.
                final Constructor<?> c = SQLException.class.getDeclaredConstructor(new Class[] {Throwable.class});
                return (SQLException)c.newInstance(new Object[]{sqlException});
            } catch ( Exception e) {
                sqlThrowable = 1;
            }
        }
        // if the code above worked correctly, then the exception will have been returned.  Otherwise, we need
        // to go through this clause and create a SQLDroidSQLException
        try {
            // avoid a direct reference to the sqldroidSQLException so that app > API level 9 do not need that class.
            final Constructor<?> c = SQLDroidConnection.class.getClassLoader().loadClass("org.sqldroid.SQLDroidSQLException").getDeclaredConstructor(new Class[] {android.database.SQLException.class});
            // SQLDroidSQLException is an instance of (direct subclass of) SQLException, so the cast below is correct although
            // the instance created will always be a SQLDroidSQLException
            return (SQLException)c.newInstance(new Object[]{sqlException});
        } catch (Exception e) {
            return new SQLException ("Unable to Chain SQLException " + sqlException.getMessage());
        }
    }
624266
private void validateExpr(SqlNode expr, SqlValidatorScope scope) {
		if (expr instanceof SqlCall) {
			final SqlOperator op = ((SqlCall) expr).getOperator();
			if (op.isAggregator() && op.requiresOver()) {
				throw newValidationError(expr,
					RESOURCE.absentOverClause());
			}
		}

		// Call on the expression to validate itself.
		expr.validateExpr(this, scope);

		// Perform any validation specific to the scope. For example, an
		// aggregating scope requires that expressions are valid aggregations.
		scope.validateExpr(expr);
	}
810830
public int[] executeBatch() throws SQLException {
        final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
        SQLExecuteCallback<int[]> callback = new SQLExecuteCallback<int[]>(getDatabaseType(), isExceptionThrown) {
            
            @Override
            protected int[] executeSQL(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
                return statement.executeBatch();
            }
        };
        List<int[]> results = executeCallback(callback);
        if (isAccumulate()) {
            return accumulate(results);
        } else {
            return results.get(0);
        }
    }
1060748
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (begin_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "begin", begin_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forEach", "begin");
            }
            begin = ((Integer) r).intValue();
            validateBegin();
        }

        if (end_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "end", end_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forEach", "end");
            }
            end = ((Integer) r).intValue();
            validateEnd();
        }

        if (step_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "step", step_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forEach", "step");
            }
            step = ((Integer) r).intValue();
            validateStep();
        }

        if (items_ != null) {
            rawItems = ExpressionEvaluatorManager.evaluate(
                    "items", items_, Object.class, this, pageContext);
            // use an empty list to indicate "no iteration", if relevant
            if (rawItems == null) {
                rawItems = new ArrayList();
            }
        }
    }
894764
@Override
	protected void handleException(final SqlContext sqlContext, final SQLException ex) throws SQLException {
		SQLException cause = ex;

		while (cause.getNextException() != null) {
			cause = cause.getNextException();
		}

		if (LOG.isErrorEnabled() && isOutputExceptionLog()) {
			StringBuilder builder = new StringBuilder();
			builder.append(System.lineSeparator()).append("Exception occurred in SQL execution.")
					.append(System.lineSeparator());
			builder.append("Executed SQL[").append(sqlContext.getExecutableSql()).append("]")
					.append(System.lineSeparator());
			if (sqlContext instanceof SqlContextImpl) {
				Parameter[] bindParameters = ((SqlContextImpl) sqlContext).getBindParameters();
				for (int i = 0; i < bindParameters.length; i++) {
					Parameter parameter = getSqlFilterManager().doParameter(bindParameters[i]);
					builder.append("Bind Parameter.[INDEX[").append(i + 1).append("], ").append(parameter.toString())
							.append("]").append(System.lineSeparator());
				}
			}
			LOG.error(builder.toString(), cause);
		}

		throw cause;
	}
660768
public Query execute(PageContext pc, SQL sql, Selects selects, int maxrows) throws PageException {
	Column[] orders = selects.getOrderbys();
	Select[] arrSelects = selects.getSelects();

	QueryImpl target = new QueryImpl(new Collection.Key[0], 0, "query", sql);

	for (int i = 0; i < arrSelects.length; i++) {
	    arrSelects[i].getFroms();
	    Column[] froms = arrSelects[i].getFroms();
	    if (froms.length > 1) throw new DatabaseException("can only work with single tables yet", null, sql, null);
	    executeSingle(pc, arrSelects[i], getSingleTable(pc, froms[0]), target, arrSelects.length > 1 ? -1 : maxrows, sql, orders.length > 0);
	}

	// Order By
	if (orders.length > 0) {
	    order(target, orders);
	    if (maxrows > -1) target.cutRowsTo(maxrows);
	}
	// Distinct
	if (selects.isDistinct()) {
	    order(target, selects.getDistincts()); // order to filter
	    // print.e(selects.getDistincts());
	    Key[] _keys = target.getColumnNames();
	    QueryColumn[] columns = new QueryColumn[_keys.length];
	    for (int i = 0; i < columns.length; i++) {
		columns[i] = target.getColumn(_keys[i]);
	    }

	    int i;
	    Object l, r;
	    outer: for (int row = target.getRecordcount(); row > 1; row--) {
		for (i = 0; i < columns.length; i++) {
		    l = columns[i].get(row, null);
		    r = columns[i].get(row - 1, null);
		    if (l == null || r == null) {
			if (l != r) continue outer;
		    }
		    else if (!Operator.equals(l, r, true)) continue outer;
		}
		target.removeRow(row);
	    }
	}
	order(target, orders);

	return target;
    }
1283470
public PreparedStatement prepareStatement(final String _sql,
                                              final String[] _strings)
        throws SQLException
    {
        return getConnection().prepareStatement(_sql, _strings);
    }
970381
public boolean execute(Sql sql) throws SQLException {
		
		long start =  System.currentTimeMillis();
		
		if (sql.validate() == false) {
			return false;
		}
		
		boolean result = false;
		
		PreparedStatement stmt = null;
		try {
			stmt = this.createStatment(conn, sql);
			stmt.execute();
			
			result = true;
		} catch (SQLException e) {
			throw e;
		} finally {
			try {
				if (stmt != null && stmt.isClosed() == false) {
					stmt.close();
				}
			} catch (SQLException e) {
				logger.error(e.getMessage(), e);
			}
		}
		
		logger.debug(String.format("Execute %s used %d ms", sql.getSql(), System.currentTimeMillis() - start));

		return result;
	}
215352
private void evaluateExpressions() throws JspException {
        if (valueEL != null) {
            value = (Date) ExpressionEvaluatorManager.evaluate(
                    "value", valueEL, Date.class, this, pageContext);
        }

        if (typeEL != null) {
            type = (String) ExpressionEvaluatorManager.evaluate(
                    "type", typeEL, String.class, this, pageContext);
        }
    }
873390
@Override
	public boolean doProcedure(final SqlContext sqlContext, final CallableStatement callableStatement,
			final boolean result) throws SQLException {
		if (getFilters().isEmpty()) {
			return result;
		}
		boolean rs = result;
		for (final SqlFilter filter : getFilters()) {
			rs = filter.doProcedure(sqlContext, callableStatement, rs);
		}
		return rs;
	}
1263089
public <E extends Object> int executeSQL(String sql, List<E> params) {
        if (params == null || params.size() == 0) {
            return jdbcTemplate.update(sql);
        } else {
            return jdbcTemplate.update(sql, params.toArray(new Object[params.size()]));
        }
    }
1309086
private int bindStatement(PreparedStatement stmt, int index, ExistsCriteria crit, ClassDescriptor cld) throws SQLException
    {
        Query subQuery = (Query) crit.getValue();

        // if query has criteria, bind them
        if (subQuery.getCriteria() != null && !subQuery.getCriteria().isEmpty())
        {
            return bindStatement(stmt, subQuery.getCriteria(), cld.getRepository().getDescriptorFor(subQuery.getSearchClass()), index);

            // otherwise, just ignore it
        }
        else
        {
            return index;
        }
    }
21250
private void sanityCheckQuery(String sql) throws SQLException
  {
    if (sql == null || sql.isEmpty())
    {
      throw new SnowflakeSQLException(SqlState.SQL_STATEMENT_NOT_YET_COMPLETE,
                                      ErrorCode.INVALID_SQL.getMessageCode(), sql);

    }
  }
54006
public Where<T, ID> in(String columnName, Iterable<?> objects) throws SQLException {
		addClause(new In(columnName, findColumnFieldType(columnName), objects, true));
		return this;
	}