sparql - errors in transaction in jena tdb? -
i trying write propreties model , query it.this part of mycode:
class="lang-java prettyprint-override">string directory = "emailaddress" ; //create dataset tdb store dataset ds = tdbfactory.createdataset(directory) ; //create default rdf model ds.begin(readwrite.write); model model = ds.getdefaultmodel() ; //write tdb dataset when write , query query shows no result ...but when interchange order of model , begin i.e.
class="lang-java prettyprint-override">model model = ds.getdefaultmodel() ; //write tdb dataset ds.begin(readwrite.write); then works fine!! gives error:
class="lang-java prettyprint-override">com.hp.hpl.jena.tdb.transaction.tdbtransactionexception: not in transaction i know first way right don't understand why doesn't respond queries..this code quering:
class="lang-java prettyprint-override">public class test4query extends object { public static string[] arr=new string[30]; public void mai (string s) { string directory = "emailaddress" ; dataset ds = tdbfactory.createdataset(directory) ; ds.begin(readwrite.read) ; model model = ds.getdefaultmodel() ; queryexecution qexec = queryexecutionfactory.create(s, ds) ; int i=0; try{ resultset rs = qexec.execselect() ; string x=rs.tostring(); while (rs.hasnext()) { querysolution qs = rs.next(); string rds; if(qs.get("x")!=null) { rds = qs.get("x").tostring(); } else { rds="hi"; } if(rds==null) { break; } system.out.println(rds); arr[i] = rds; i++; } } {qexec.close() ; ds.commit(); ds.end(); } } }
it unclear when hat exception. code illustration total of parts commented out , not utilize "m" @ all.
you can not phone call resultsetformatter.out(rs) after have called qexec.close or ds.commit.
error-handling sparql jena tdb
No comments:
Post a Comment