Skip to content

Instantly share code, notes, and snippets.

@AlBaker
Created June 24, 2014 16:15
Show Gist options
  • Save AlBaker/956b641b9954e2031a2e to your computer and use it in GitHub Desktop.
Save AlBaker/956b641b9954e2031a2e to your computer and use it in GitHub Desktop.
Stardog Sparql Update
// presume part of a class that has access to a ConnectionPool
/*
* @param sparql - the SPARQL Update String to process
* @param args - a map of String,Object that will be used to bind query variables
*/
public void update(String sparql, Map<String, Object> args) {
Connection connection = pool.obtain();
try {
UpdateQuery query = connection.update(sparql);
if (args != null) {
for (Entry<String, Object> arg : args.entrySet()) {
query.parameter(arg.getKey(), arg.getValue());
}
}
query.execute();
} catch (StardogException e) {
log.error("Error sending query to Stardog", e);
throw new RuntimeException(e);
} finally {
pool.releaseConnection(connection);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment