eclipse - Load RDF model into Jena SDB -
i trying load rdf model jena sdb. have done connection (and think should fine). not know why not work right. think because of arq library have imported project not know.
here code :
string rdf_file = "./prova_rules_m_rdf.owl"; string classname = "com.mysql.jdbc.driver"; string db_url = "jdbc:mysql://localhost:3306/prova_rules"; string db_user = "root"; string db_passwd = ""; // create store description storedesc storedesc = new storedesc(layouttype.layouttriplenodeshash,databasetype.mysql); // load database driver try { class.forname(classname); system.out.println("jdbc driver load successfully!"); } catch (exception e) { e.printstacktrace(); } // create sdbconnection sdbconnection sdbconnection = new sdbconnection(db_url,db_user,db_passwd); // connect store store store = sdbfactory.connectstore(sdbconnection,storedesc); // connect store dataset dataset dataset = sdbfactory.connectdataset(store); // prepare model model tmpmodel = modelfactory.createdefaultmodel(); filemanager.get().readmodel(tmpmodel,rdf_file,"owl"); system.out.println(tmpmodel.size()); // add model dataset dataset.getdefaultmodel().add(tmpmodel); // done ... store.close(); }
here error:
exception in thread "main" java.lang.nosuchmethoderror: com.hp.hpl.jena.query.arq.getcontext()lcom/hp/hpl/jena/sparql/util/context; @ com.hp.hpl.jena.sdb.sdb.initworker(sdb.java:87) @ com.hp.hpl.jena.sdb.sdb.(sdb.java:61) @ com.hp.hpl.jena.sdb.store.storefactory.(storefactory.java:40) @ com.hp.hpl.jena.sdb.sdbfactory.connectstore(sdbfactory.java:117) @ createontmodel.main(createontmodel.java:94)
nosuchmethoderror
indicates have inconsistent set of jars on runtime classpath (eclipse build path). make sure have 1 copy of each jena jar on project build path well.
using maven eclipse manage dependencies automatically.
Comments
Post a Comment