Search in sources :

Example 1 with UpdateExecutionException

use of org.eclipse.rdf4j.query.UpdateExecutionException in project rdf4j by eclipse.

the class SPARQLUpdateOperation method execute.

public void execute(RepositoryConnection con) throws RepositoryException {
    try {
        Update preparedUpdate = con.prepareUpdate(QueryLanguage.SPARQL, getUpdateString(), getBaseURI());
        preparedUpdate.setIncludeInferred(isIncludeInferred());
        preparedUpdate.setDataset(getDataset());
        if (getBindings() != null) {
            for (Binding binding : getBindings()) {
                preparedUpdate.setBinding(binding.getName(), binding.getValue());
            }
        }
        preparedUpdate.execute();
    } catch (MalformedQueryException e) {
        throw new RepositoryException(e);
    } catch (UpdateExecutionException e) {
        throw new RepositoryException(e);
    }
}
Also used : Binding(org.eclipse.rdf4j.query.Binding) UpdateExecutionException(org.eclipse.rdf4j.query.UpdateExecutionException) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) Update(org.eclipse.rdf4j.query.Update)

Example 2 with UpdateExecutionException

use of org.eclipse.rdf4j.query.UpdateExecutionException in project rdf4j by eclipse.

the class SPARQLConnection method commit.

public void commit() throws RepositoryException {
    synchronized (transactionLock) {
        if (isActive()) {
            synchronized (transactionLock) {
                SPARQLUpdate transaction = new SPARQLUpdate(client, null, sparqlTransaction.toString());
                try {
                    transaction.execute();
                } catch (UpdateExecutionException e) {
                    throw new RepositoryException("error executing transaction", e);
                }
                sparqlTransaction = null;
            }
        } else {
            throw new RepositoryException("no transaction active.");
        }
    }
}
Also used : UpdateExecutionException(org.eclipse.rdf4j.query.UpdateExecutionException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) SPARQLUpdate(org.eclipse.rdf4j.repository.sparql.query.SPARQLUpdate)

Aggregations

UpdateExecutionException (org.eclipse.rdf4j.query.UpdateExecutionException)2 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)2 Binding (org.eclipse.rdf4j.query.Binding)1 MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)1 Update (org.eclipse.rdf4j.query.Update)1 SPARQLUpdate (org.eclipse.rdf4j.repository.sparql.query.SPARQLUpdate)1