Executing Xquery update from java - hangs

Wednesday, 25 February 2015 · 3 messages · last reply 26 Feb 2015
KF
Ketill Fenne25 Feb 2015 17:02 #
Hi! I am executing all Xqueries through the same runQuery method in Java, and I am running the latest jar-files (8.0.1):
            XQDataSource ds = new BaseXXQDataSource();
            xqc = ds.getConnection();
            XQExpression xqe = xqc.createExpression();
            rs = xqe.executeQuery(query);

The query is (in this case):
for $doc in (collection('Users/customer_1'))/*
return (replace value of node $doc/@name with ("My new customer name"))
The update works fine in BaseX Gui, and I suspect the problem is that it does not return anything, and my code expects XQResultSequence. I have tried adding db:output to return part of the query with no luck. Do you have any suggestions? Kind regards Ketill Fenne
CG
Christian Grün25 Feb 2015 17:23 #
Hi Ketill, Welcome to our list. XQJ was written to be compliant with XQuery 1.0, so it may well be that the db:output extension cannot be used with our (well, Charles Foster's) implementation of XQJ (yet). Have you tried to set the MIXUPDATES flag to true instead? All the best, Christian
Quoted text · Ketill Fenne · 22 lines
On Wed, Feb 25, 2015 at 5:02 PM, Ketill Fenne <ketill.fenne at gmail.com> wrote: > Hi! > > I am executing all Xqueries through the same runQuery method in Java, and I > am running the latest jar-files (8.0.1): > > XQDataSource ds = new BaseXXQDataSource(); > xqc = ds.getConnection(); > XQExpression xqe = xqc.createExpression(); > rs = xqe.executeQuery(query); > > The query is (in this case): > for $doc in (collection('Users/customer_1'))/* > return (replace value of node $doc/@name with ("My new customer name")) > > The update works fine in BaseX Gui, and I suspect the problem is that it > does not return anything, and my code expects XQResultSequence. I have tried > adding db:output to return part of the query with no luck. > Do you have any suggestions? > > Kind regards > Ketill Fenne
CG
Christian Grün26 Feb 2015 10:50 #
Hi Ketill, I'm cc'ing this back to the mailing list, as it may also be of interest for other users.
Quoted text · Christian Grün · 3 lines
> Would you advice against mixing different "connection methods" to the > database(s) in the same application? (Queries through XQJ, updates via > QueryProcessor)
Using a single API will usually cause you less headache in the middle or long term, but it may be fine to simply try out things. If you create QueryProcessor instances, no problems are to be expected as long as you dont't need to run concurrent queries. You could also work with LocalSession instances, which will be more stable in the long run. The (Local|Client)Session API could be further extended to meet more requirements, depending on the feedback we get. Hope this helps, Christian
Quoted text · Christian Grün · 43 lines
> On Wed, Feb 25, 2015 at 5:23 PM, Christian Grün <christian.gruen at gmail.com> > wrote: >> >> Hi Ketill, >> >> Welcome to our list. >> >> XQJ was written to be compliant with XQuery 1.0, so it may well be >> that the db:output extension cannot be used with our (well, Charles >> Foster's) implementation of XQJ (yet). Have you tried to set the >> MIXUPDATES flag to true instead? >> >> All the best, >> Christian >> >> >> On Wed, Feb 25, 2015 at 5:02 PM, Ketill Fenne <ketill.fenne at gmail.com> >> wrote: >> > Hi! >> > >> > I am executing all Xqueries through the same runQuery method in Java, >> > and I >> > am running the latest jar-files (8.0.1): >> > >> > XQDataSource ds = new BaseXXQDataSource(); >> > xqc = ds.getConnection(); >> > XQExpression xqe = xqc.createExpression(); >> > rs = xqe.executeQuery(query); >> > >> > The query is (in this case): >> > for $doc in (collection('Users/customer_1'))/* >> > return (replace value of node $doc/@name with ("My new customer name")) >> > >> > The update works fine in BaseX Gui, and I suspect the problem is that it >> > does not return anything, and my code expects XQResultSequence. I have >> > tried >> > adding db:output to return part of the query with no luck. >> > Do you have any suggestions? >> > >> > Kind regards >> > Ketill Fenne > >

⚡Generated with XQuery