dataSource.releaseConnection(connection);
}
}
public void singleton(String subject, String predicate, Object object, String graphUri) {
Connection connection = dataSource.getConnection();
URIImpl subjectResource = null;
URIImpl predicateResource = null;
Resource context = null;
if (subject != null) {
subjectResource = new URIImpl(subject);
}
if (predicate != null) {
predicateResource = new URIImpl(predicate);
}
if (graphUri != null) {
context = ValueFactoryImpl.getInstance().createURI(graphUri);
}
Value objectValue = TypeConverter.asLiteral(object);
try {
connection.begin();
connection.remove().statements(subjectResource, predicateResource, null, context);
connection.add().statement(subjectResource, predicateResource, objectValue, context);
connection.commit();
} catch (StardogException e) {
log.error("Error with remove statement", e);
throw new RuntimeException(e);
} finally {
dataSource.releaseConnection(connection);