RepositoryConnection connection2 = repository.getConnection();
try {
String query = String.format("DELETE { <%s> <%s> ?v } INSERT { <%s> <%s> ?v . } WHERE { <%s> <%s> ?v }", subject.stringValue(), predicate.stringValue(), subject.stringValue(), predicate.stringValue(), subject.stringValue(), predicate.stringValue());
Update u = connection2.prepareUpdate(QueryLanguage.SPARQL, query);
u.execute();
connection2.commit();
} finally {
connection2.close();