Thanks, Mike.
Your pointers were very helpful. I actually knew I could access an existing server (and I was doing it). I just asked if there already existed real examples of code interacting with Jena models and Stardog.
I could create a database in both memory and disk from a file with no problems ( .create( myFile ) ). However, when I try to load data from a Java OntModel, I don't get all the triples (it seems the OWL information is lost, like classes were rdfs:Class and not owl:Class, and therefore they don't appear in the "Browse" menu option of my Stardog database) Can this be because SDJenaFactory uses Model instead of OntModel?
aModel = SDJenaFactory.createModel(aConn);
OntModel o2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, aModel);
o2.begin();
o2= (OntModel) o2.add( my_OntModel );
o2.commit();
o2.close();
And this:
aModel = SDJenaFactory.createModel(aConn);
aModel.begin();
aModel= aModel.add( (Model) my_OntModel );
aModel.commit();
And both seem to have the same results - only partial information is stored.
I've collected some notes that might be useful for others:
- The examples use the embedded mode. Connecting to an existing Stardog can be done via:
aAdminConnection = AdminConnectionConfiguration.toServer("snarl://localhost:5820").credentials("admin", "admin").connect();
- Starting Stardog from a Java application required me to have the licence file in the "." directory of the Java app. Not sure why STARDOG_HOME was not properly accessed.
- I believe the Stardog server cannot be started twice, so make sure your Java code close the server properly (use a "finally" block). If problems happen, Stardog is down but it does not start because it believes there is another copy working: delete the file "system.lock" (note there might be some data corruption if you didn't close properly!)
- When creating a database, the initial file load from ".create( myFile )" seems to use the extension of the file to identify the format. So having an N3 file with no .n3 extension will raise an exception and will not be recognized.