Created
June 24, 2014 16:15
-
-
Save AlBaker/956b641b9954e2031a2e to your computer and use it in GitHub Desktop.
Stardog Sparql Update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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