Unable to create named graphs

4 views
Skip to first unread message

timmy....@gmail.com

unread,
Jan 9, 2015, 3:52:16 AM1/9/15
to sta...@clarkparsia.com
Hi,

I'm unable to create named graphs. I've tried to do this in the admin console and with the Jena API, but without luck.

Admin console: 

Jena code:
final Connection conn = ConnectionConfiguration.to(DATABASE_NAME).server(SNARL_URL).connect();
final Dataset dataset = SDJenaFactory.createDataset(conn);
dataset.begin(ReadWrite.WRITE);
dataset.addNamedModel("http://url.com/graph_name", ModelFactory.createDefaultModel());
// OR : final Model model = dataset.getNamedModel("http://url.com/graph_name");
dataset.commit();

Why doesn't this work out of the box? Thanks.

timmy....@gmail.com

unread,
Jan 9, 2015, 4:39:53 AM1/9/15
to sta...@clarkparsia.com, timmy....@gmail.com
A small update, I've tried the following line of code as well:

conn.graph("create graph <http://url.com/graph_namae>").execute();

but it seems to be buggy (or I'm totally not getting it :-))

java.lang.Boolean cannot be cast to org.openrdf.query.GraphQueryResult



Mike Grove

unread,
Jan 9, 2015, 6:24:38 AM1/9/15
to stardog
As mentioned in the docs [1], the `Connection#graph` method is for creating graph queries, not update queries.  For updates, you must use the `update` method.

Please note, there's no notion of a graph which exists, but is empty, in Stardog.  To "create" a named graph, simply add triples to it.

Cheers,

Mike

 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

timmy....@gmail.com

unread,
Jan 9, 2015, 7:36:53 AM1/9/15
to sta...@clarkparsia.com
Understood, but the reason I tried Connection#Graph is because the update method did not create it as well. Also, I've had multiple occasions where Dataset#getModel("") returned a NullPointerException, before I could add triples.

Nevertheless, somehow, I've now got the graphs I needed. If I have more input, I'll add them to this topic. 
Reply all
Reply to author
Forward
0 new messages