I am new to Jena-TDB and SPARQL, so this might be a dumb question. I am using tdb-0.9.0 on Windows XP.
I am creating a TDB model for my file trail_1.rdf. My understanding here (correct me if I am wrong) is that the following code will read the given rdf file in the TDB model, and also save / load (not sure which is the best word) model in this directory D:\Project\Store_DB\data1\tdb:
String directory = "D:\\Project\\Store_DB\\data1\\tdb";
Dataset dataset = TDBFactory.createDataset(directory);
Model tdb = dataset.getDefaultModel();
String source = "D:\\Project\\Store_DB\\tmp\\trail_1.rdf";
FileManager.get().readModel( tdb, source);
tdb.close();
dataset.close();
Is this understanding correct?
In accordance with my understanding, since the model has been stored in the directory D:\Project\Store_DB\data1\tdb, I should be able to run a request on it at some later point in time.
So, to request TDB storage in D:\Project\Store_DB\data1\tdb, I tried the following, but it doesn't print anything:
String directory = "D:\\Project\\Store_DB\\data1\\tdb" ;
Dataset dataset = TDBFactory.createDataset(directory) ;
Iterator<String> graphNames = dataset.listNames();
while (graphNames.hasNext()) {
String graphName = graphNames.next();
System.out.println(graphName);
}
I also tried this, which also did not print anything:
String directory = "D:\\Project\\Store_DB\\data1\\tdb" ;
Dataset dataset = TDBFactory.createDataset(directory) ;
String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
Query query = QueryFactory.create(sparqlQueryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
ResultSet results = qexec.execSelect() ;
ResultSetFormatter.out(results) ;
? - , ?