LocalSession delete document - No database opened
Friday, 27 February 2015 · 2 messages
KF
Ketill Fenne27 Feb 2015 14:56 #
Hi!
I am trying to delete a specific document from a database called Users, but get the error "org.basex.core.BaseXException; No database opened"
The code is (input name is the document name):
Context context = new Context();
LocalSession session = new LocalSession(context);
try {
new Open("Users").execute(context);
session.execute("delete " + name);
} catch (Exception e) {
e.printStackTrace(); // let the caller handle exception
throw e;
}Do I need to open the database through the session? Haven't found out how....
BR
Ketill Fenne
CG
Christian Grün27 Feb 2015 15:35 #
Hi Ketill,
try this:
session.execute("open Users");
Best,
Christian
Quoted text · Ketill Fenne · 23 lines
On Fri, Feb 27, 2015 at 2:56 PM, Ketill Fenne <ketill.fenne at gmail.com> wrote: > Hi! > > I am trying to delete a specific document from a database called Users, but > get the error "org.basex.core.BaseXException; No database opened" > > The code is (input name is the document name): > > Context context = new Context(); > LocalSession session = new LocalSession(context); > try { > new Open("Users").execute(context); > session.execute("delete " + name); > } catch (Exception e) { > e.printStackTrace(); // let the caller handle exception > throw e; > } > > Do I need to open the database through the session? Haven't found out > how.... > > BR > Ketill Fenne
Written for BaseX 8.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery