overload for prepareUpdate

@param queryString
@param baseURI
@return MarkLogicUpdateQuery
@throws RepositoryException
@throws MalformedQueryException
966461
@Override
    public MarkLogicUpdateQuery prepareUpdate(String queryString,String baseURI) throws RepositoryException, MalformedQueryException {
        return prepareUpdate(QueryLanguage.SPARQL, queryString, baseURI);
    }
916573
protected int update (final String query)
        throws PersistenceException
    {
        return executeUpdate(new Operation<Integer>() {
            public Integer invoke (Connection conn, DatabaseLiaison liaison)
                throws SQLException, PersistenceException
            {
                Statement stmt = null;
                try {
                    stmt = conn.createStatement();
                    return stmt.executeUpdate(query);
                } finally {
                    JDBCUtil.close(stmt);
                }
            }
        });
    }
1367649
@Override
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        int result = -1;

        if (!controller.hasPreinitialized()) {
            throw new IllegalStateException("Controller has not been initialized.");
        }

        int patternCode = controller.getUriMatcher().match(uri);
        MatcherPattern pattern = controller.findMatcherPattern(patternCode);
        if (pattern == null) {
            throw new IllegalArgumentException("unknown uri : " + uri.toString());
        }

        Parameter parameter = new Parameter(uri, values, selection, selectionArgs);
        SQLiteDatabase db = this.getHelper().getWritableDatabase();

        result = onUpdate(this.getHelper(), db, pattern, parameter);
        if (result >= 0) {
            this.onUpdateCompleted(result, uri, pattern, parameter);
        }
        return result;
    }
1287140
public void sendUpdateQuery(String queryString, SPARQLQueryBindingSet bindings, boolean includeInferred, String baseURI) throws IOException, RepositoryException, MalformedQueryException,UpdateExecutionException {
		getClient().performUpdateQuery(queryString, bindings, this.tx, includeInferred, baseURI);
	}
998571
public URI changesUri(String queryKey, Object queryValue) {

        if(queryKey.equals("since")){
            if(!(queryValue instanceof String)){
                //json encode the seq number since it isn't a string
                Gson gson = new Gson();
                queryValue = gson.toJson(queryValue);
            }
        }
        return this.path("_changes").query(queryKey, queryValue).build();
    }
1345104
public void addRegexQueryParameters( List<String> inputParams, String listId, String fieldName, boolean union ) {
        addRegexQueryParameters(inputParams, listId, fieldName, null, union);
    }
300259
@SuppressWarnings("unused")
    final void handleQueryParameters(ByteBuffer buffer, ParseState state, HttpServerExchange exchange) throws BadRequestException {
        StringBuilder stringBuilder = state.stringBuilder;
        int queryParamPos = state.pos;
        int mapCount = state.mapCount;
        boolean urlDecodeRequired = state.urlDecodeRequired;
        String nextQueryParam = state.nextQueryParam;

        //so this is a bit funky, because it not only deals with parsing, but
        //also deals with URL decoding the query parameters as well, while also
        //maintaining a non-decoded version to use as the query string
        //In most cases these string will be the same, and as we do not want to
        //build up two separate strings we don't use encodedStringBuilder unless
        //we encounter an encoded character

        while (buffer.hasRemaining()) {
            char next = (char) (buffer.get() & 0xFF);
            if(!allowUnescapedCharactersInUrl && !ALLOWED_TARGET_CHARACTER[next]) {
                throw new BadRequestException(UndertowMessages.MESSAGES.invalidCharacterInRequestTarget(next));
            }
            if (next == ' ' || next == '\t') {
                final String queryString = stringBuilder.toString();
                exchange.setQueryString(queryString);
                if (nextQueryParam == null) {
                    if (queryParamPos != stringBuilder.length()) {
                        exchange.addQueryParam(decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true), "");
                    }
                } else {
                    exchange.addQueryParam(nextQueryParam, decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true));
                }
                state.state = ParseState.VERSION;
                state.stringBuilder.setLength(0);
                state.pos = 0;
                state.nextQueryParam = null;
                state.urlDecodeRequired = false;
                state.mapCount = 0;
                return;
            } else if (next == '\r' || next == '\n') {
                throw UndertowMessages.MESSAGES.failedToParsePath();
            } else {
                if (decode && (next == '+' || next == '%' || next > 127)) { //+ is only a whitespace substitute in the query part of the URL
                    urlDecodeRequired = true;
                } else if (next == '=' && nextQueryParam == null) {
                    nextQueryParam = decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true);
                    urlDecodeRequired = false;
                    queryParamPos = stringBuilder.length() + 1;
                } else if (next == '&' && nextQueryParam == null) {
                    if (++mapCount >= maxParameters) {
                        throw UndertowMessages.MESSAGES.tooManyQueryParameters(maxParameters);
                    }
                    if (queryParamPos != stringBuilder.length()) {
                        exchange.addQueryParam(decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true), "");
                    }
                    urlDecodeRequired = false;
                    queryParamPos = stringBuilder.length() + 1;
                } else if (next == '&') {
                    if (++mapCount >= maxParameters) {
                        throw UndertowMessages.MESSAGES.tooManyQueryParameters(maxParameters);
                    }
                    exchange.addQueryParam(nextQueryParam, decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true));
                    urlDecodeRequired = false;
                    queryParamPos = stringBuilder.length() + 1;
                    nextQueryParam = null;
                }
                stringBuilder.append(next);

            }

        }
        state.pos = queryParamPos;
        state.nextQueryParam = nextQueryParam;
        state.urlDecodeRequired = urlDecodeRequired;
        state.mapCount = mapCount;
    }
719378
@Override
	public CreateOrUpdateStatus createOrUpdate(Contents contents)
			throws SQLException {
		verifyCreate(contents);
		return super.createOrUpdate(contents);
	}
728175
@Override
    public synchronized int executeUpdate(final String query) throws DatabaseEngineException {
        Statement s = null;
        try {
            getConnection();
            s = conn.createStatement();
            return s.executeUpdate(query);
        } catch (final Exception ex) {
            throw new DatabaseEngineException("Error handling native query", ex);
        } finally {
            if (s != null) {
                try {
                    s.close();
                } catch (final Exception e) {
                    logger.trace("Error closing statement.", e);
                }
            }
        }
    }
255225
@Override
    public synchronized int executeUpdate(String query) throws DatabaseEngineException {
        String[] split = query.split(Constants.UNIT_SEPARATOR_CHARACTER + "");
        int i = -1;
        for (String s : split) {
            if (StringUtils.isNotBlank(s)) {
                i = super.executeUpdate(s);
            }
        }

        return i;
    }
1141654
public ApiResponse<QueryResponse> executeQueryPostWithHttpInfo(Query query) throws ApiException {
        com.squareup.okhttp.Call call = executeQueryPostValidateBeforeCall(query, null, null);
        Type localVarReturnType = new TypeToken<QueryResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
619648
public void performAdd(String baseURI, Resource subject, URI predicate, Value object, Transaction tx, Resource... contexts) throws MarkLogicSesameException {
        StringBuilder sb = new StringBuilder();
        if(notNull(contexts) && contexts.length>0) {
            if (notNull(baseURI)) sb.append("BASE <" + baseURI + ">\n");
            sb.append("INSERT DATA { ");
            for (int i = 0; i < contexts.length; i++) {
                if (notNull(contexts[i])) {
                    sb.append("GRAPH <" + contexts[i].stringValue() + "> { ?s ?p ?o .} ");
                } else {
                    sb.append("GRAPH <" + DEFAULT_GRAPH_URI + "> { ?s ?p ?o .} ");
                }
            }
            sb.append("}");
        } else {
            sb.append("INSERT DATA { GRAPH <" + DEFAULT_GRAPH_URI + "> {?s ?p ?o .}}");
        }
        SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(sb.toString());
        if (notNull(ruleset) ) {qdef.setRulesets(ruleset);}
        if(notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);}
        if(notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);}

        if(notNull(subject)) qdef.withBinding("s", subject.stringValue());
        if(notNull(predicate)) qdef.withBinding("p", predicate.stringValue());
        if(notNull(object)) bindObject(qdef, "o", object);
        sparqlManager.executeUpdate(qdef, tx);
    }
1039771
private static Object readQueryString(String queryName,
                                          Class<?> paramType,
                                          Type genericType,
                                          Annotation[] paramAnns,
                                          Message m,
                                          String defaultValue,
                                          boolean decode) {

        MultivaluedMap<String, String> queryMap = new UriInfoImpl(m, null).getQueryParameters(decode);

        if ("".equals(queryName)) {
            return InjectionUtils.handleBean(paramType, paramAnns, queryMap, ParameterType.QUERY, m, false);
        }
        return InjectionUtils.createParameterObject(queryMap.get(queryName),
                                                    paramType,
                                                    genericType,
                                                    paramAnns,
                                                    defaultValue,
                                                    false,
                                                    ParameterType.QUERY, m);
    }
41714
private UriTuple parseUriTuple(String uri, Map<String, String[]> params) throws UnsupportedEncodingException {

		String requestUri = null;
		String queryString = "";  // default
		
		final int queryStringBegin = uri.indexOf("?");
		if (queryStringBegin == -1) {
			// Simple case -- no querystring
			requestUri = uri;
		} else {
			// Complex case -- uri+querystring
			requestUri = uri.substring(0, queryStringBegin);
			queryString = uri.substring(queryStringBegin);  // will already contain the '?' character
		}
		
		// Inject requestUri params
		for (Map.Entry<String, String[]> y : params.entrySet()) {
			final String token = "{" + y.getKey() + "}";
			final String[] values = y.getValue();
			switch (values.length) {
				case 0:
					// Strange -- I guess we omit it?
					while(requestUri.contains(token)) {
						// Don't use String.replaceAll b/c token looks like an illegal regex
						requestUri = requestUri.replace(token, "");
					}
					break;
				case 1:
					// This is healthy & normal
					final String inject = URLEncoder.encode(values[0], "UTF-8");
					while(requestUri.contains(token)) {
						// Don't use String.replaceAll b/c token looks like an illegal regex
						requestUri = requestUri.replace(token, inject);
					}
					break;
				default:
					// OOPS! --  can't have more than 1 value for a requestUri token
					final String msg = "Can't support multiple values for non-querystring URI token:  " + token;
					throw new IllegalArgumentException(msg);
			}
		}
		
		// Inject queryString params
		for (Map.Entry<String, String[]> y : params.entrySet()) {
			final String paramName = y.getKey();
			final String token = "{" + paramName + "}";
			if (queryString.contains(token)) {
				final StringBuilder value = new StringBuilder();
				for (String s : y.getValue()) {
					final String inject = URLEncoder.encode(s, "UTF-8");
					value.append(value.length() != 0 ? "&" : "");
					value.append(paramName).append("=").append(inject);
				}
				queryString = queryString.replace(token, value);
			}
		}
		
		// Split into contextName+uri
		final int contextSeparatorPos = requestUri.indexOf("/", 1);  // A valid input starts with a slash, followed by the contextName
		final String contextName = requestUri.substring(0, contextSeparatorPos);  // Includes leading '/'
		requestUri = requestUri.substring(contextSeparatorPos);  // Includes leading '/'

		return new UriTuple(contextName, requestUri + queryString);
		
	}
289405
private void generateQuery(SQLiteDatabaseSchema schema) {
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("query").addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).returns(Cursor.class);
		methodBuilder.addParameter(Uri.class, "uri");
		methodBuilder.addParameter(ParameterSpec.builder(TypeUtility.arrayTypeName(String.class), "projection").build());
		methodBuilder.addParameter(String.class, "selection");
		methodBuilder.addParameter(ParameterSpec.builder(TypeUtility.arrayTypeName(String.class), "selectionArgs").build());
		methodBuilder.addParameter(String.class, "sortOrder");

		boolean hasOperation = hasOperationOfType(schema, methodBuilder, JQLType.SELECT);

		if (!hasOperation) {
			methodBuilder.addStatement("throw new $T(\"Unknown URI for $L operation: \" + uri)", IllegalArgumentException.class, JQLType.SELECT);
			classBuilder.addMethod(methodBuilder.build());
			return;
		}

		methodBuilder.addStatement("$T returnCursor=null", Cursor.class);

		for (SQLiteDaoDefinition daoDefinition : schema.getCollection()) {
			for (SQLiteModelMethod daoMethod : daoDefinition.getCollection()) {
				if (daoMethod.jql.operationType != JQLType.SELECT)
					continue;
				// methodBuilder.addJavadoc("method $L.$L\n",
				// daoDefinition.getName(), daoMethod.getName());
			}
		}

		defineJavadocHeaderForContentOperation(methodBuilder, "query");

		methodBuilder.beginControlFlow("switch (sURIMatcher.match(uri))");
		for (Entry<String, ContentEntry> item : uriSet.entrySet()) {
			if (item.getValue().select == null)
				continue;

			defineJavadocForContentUri(methodBuilder, item.getValue().select);

			// methodBuilder.addJavadoc("uri $L\n", item.getKey());

			methodBuilder.beginControlFlow("case $L:", item.getValue().pathIndex);
			methodBuilder.addCode("// URI: $L\n", item.getValue().select.contentProviderUri());
			methodBuilder.addStatement("returnCursor=dataSource.get$L().$L(uri, projection, selection, selectionArgs, sortOrder)", item.getValue().select.getParent().getName(),
					item.getValue().select.contentProviderMethodName);
			methodBuilder.addStatement("break");
			methodBuilder.endControlFlow();
		}
		methodBuilder.beginControlFlow("default:");
		methodBuilder.addStatement("throw new $T(\"Unknown URI for $L operation: \" + uri)", IllegalArgumentException.class, JQLType.SELECT);
		methodBuilder.endControlFlow();

		methodBuilder.endControlFlow();

		defineJavadocFooterForContentOperation(methodBuilder);

		if (hasOperation) {
			methodBuilder.addStatement("return returnCursor");
		}

		classBuilder.addMethod(methodBuilder.build());
	}
1072398
public function query($queryString, array $queryValues = [])
    {
        if (!is_string($queryString) || empty($queryString)) {
            throw new \InvalidArgumentException(
                __METHOD__.': The specified query is not valid.'
            );
        }

        $this->connect();
        $this->resourceHandle = $this->dbConnection->prepare($queryString);

        try {
            // start transaction
            $this->dbConnection->beginTransaction();

            // execute the query and return a status
            $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null);

            // get last inserted id if present
            $this->lastInsertedId = $this->dbConnection->lastInsertId();

            // finally execute the query
            $this->dbConnection->commit();
        } catch (\PDOException $ex) {
            // If an error occurs, execute rollback
            $this->dbConnection->rollBack();

            // Return execution status to false
            $this->executionStatus = false;
            $this->resourceHandle->closeCursor();

            throw new \RuntimeException(
                __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}"
            );
        }

        return $this->resourceHandle;
    }
1351101
public boolean sendBooleanQuery(String queryString, SPARQLQueryBindingSet bindings, boolean includeInferred, String baseURI) throws IOException, RepositoryException, MalformedQueryException,
			QueryInterruptedException {
		return getClient().performBooleanQuery(queryString, bindings, this.tx, includeInferred, baseURI);
	}