You may want to determine which route you're going to take. If you use the methods from Part 4 you have more control of what is being passed to Jena. Additionally, you're controlling the triple store and models directly instead of letting SPARQL do the work. It's your call.
import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.update.UpdateAction;
...
public static boolean sparqlUpdater(String query, String modelName) throws Exception {
IDBConnection dbcon = initDBStore(M_DB_URL, M_DB_USER, M_DB_PASSWD, M_DB_TYPE,
CLEAN_DB);
ModelMaker maker = initModel(dbcon);
Model model = maker.openModel(modelName);
// the UpdateAction obj does all the hard work now.
// there is a slight bug in this version of Jena that requires the new
// QuerySolutionMap obj created. I believe this is fixed in the SVN.
UpdateAction.parseExecute(query, model, new QuerySolutionMap());
model.close();
maker.close();
dbcon.close();
return true;
}
Obviously, surround that in some try/catch business and remember this requires Jena 2.5.6 (newest version at the time of this writing.) So get that in your -classpath and get rid of the old stuff. This should greatly simplify CRUD activities with Jena persistent store. One other thing to note, although you can use a SPARQL select through this method, I wouldn't. This only returns a boolean whereas our sparqlSelect() method returned a
String[][].
1 comments:
Hi I have been looking for a way to implement web services using jena and this is great!! But you say this is for Axis1, is there any way of using this with Axis2?
Post a Comment