Namespaces are added to the database automatically only at database
creation time (db create command in CLI). Files added later (using
data add CLI command or the API call you mention) will not change the
stored namespaces. The API call that corresponds to db create command
so:
// create an admin connection
AdminConnection aAdminConnection = ...
// create a disk db with given file(s) whose namespaces will be stored
aAdminConnection.disk("dbName").create(file1, file2, ...);
You also have the option of adding the namespaces manually using the
API after db creation. It would look something like this:
// import com.complexible.common.rdf.rio.RDFStreams;
// Create Stardog connection as usual
Connection conn = ...
// Get namespaces object
final Namespaces ns = aConn.namespaces();
// Parse the file contents and add the namespace declaration to the database
RDFStreams.forFile(new File("filePath")).parse(new RDFHandlerBase() {
@Override
public void handleNamespace(String prefix, String uri) throws
RDFHandlerException {
try {
ns.add(prefix, uri);
}
catch (NamespacesException e) {
// do error handling
}
}
});
Best,
Evren