I am creating a new database in stardog using java.
When I am creating the database and importing a RDF file in localhost its working.
But when I am creating db in remote server I am getting a file not found exception for the same RDF file.
Please take a look at my code
System.out.println("start updating db");
String myDBName = "myDB" ;
StardogDBMS dbms =
//StardogDBMS.toServer("snarl://localhost:5820/")
StardogDBMS.toServer("snarl://myRemoteServer:5820/")
.credentials("admin", "admin".toCharArray()).login();
File file = new File("src\\main\\webapp\\test.rdf"))
System.out.println("creating " + myDBName +" and loading the rdf file" );
dbms.disk(myDBName).create(file));
dbms.logout();
System.out.println("created " + myDBName +" and loaded the rdf file" );
please help. Is there any turnaround like passing a stream to database for importing RDF file. Here is the exception I am getting.
start updating db
creating myDB and loading the rdf file
File: xxx\xxxx\test.RDF Message: java.io.FileNotFoundException: xxx\xxxx\test.RDF (No such file or directory)
created myDB and loaded the rdf file
I guess what Michael answered is the reason for the exception. I found a go around method for this issue.
Instead of creating database and bulk loading the RDF/OWL files. Create a connection to the stardog DB. and import the RDF files through the connection.
sample code is given below
System.out.println("start updating db");
String myDBName = "myDB" ;
StardogDBMS dbms =
//StardogDBMS.toServer("snarl://localhost:5820/")
StardogDBMS.toServer("snarl://myRemoteServer:5820/")
.credentials("admin", "admin".toCharArray()).login();
File file = new File("src\\main\\webapp\\test.rdf"))
System.out.println("creating " + myDBName);
dbms.disk(myDBName).create());
dbms.logout();
aConn = ConnectionConfiguration.to(myDBName) // the name of the db to connect to
.credentials("admin", "admin") // the credentials with which to connect
.url("snarl://myRemoteServer:5820/")
.connect(); // now open the connection
System.out.println("importing files to "+myDBName);
aConn.begin();
aConn.add().io().format(RDFFormat.RDFXML).stream(file);
aConn.commit();
System.out.println("files imported to "+myDBName);
System.out.println("DB Updated");