XQJ: "Error: [BXDB0007] Database 'factbook' is opened by another process" on server is not propagated to Java code?
Hi all, Maybe this is related to http://xqj.net/basex/ instead of BaseX itself, but as I don't know allow me to ask here first. Whenever I have somehow locked a BaseX database, like by using the standalone command line utility or the GUI, then I get something like the following in the BaseX log files: QUERY(1) for $c in collection('factbook')//country[name='Albania']return( replace value of node $c/@population with xs:integer($c/@population + 1)) OK 39.92 ms QUERY(1) OK 0.62 ms FULL(1) Error: [BXDB0007] Database 'factbook' is opened by another process. CLOSE(1) OK 39.68 ms Good. However, I don't see that error in my Java code. The Java code just continues like all was fine. Can I somehow make the Java code fail when this happens? See example below, and the same thing in the attachment. Thanks, Arjan. private static final String DRIVER = "net.xqj.basex.BaseXXQDataSource"; private static final String SELECT = "xs:long(collection('factbook')//country[name='Albania']/@population[1]/data(.))"; private static final String UPDATE = "for $c in collection('factbook')//country[name='Albania']" + "return(" + " replace value of node $c/@population with xs:integer($c/@population + 1)" + ")"; @Test public void testUpdate() { try { XQDataSource xqd = (XQDataSource) Class.forName(DRIVER) .newInstance(); XQConnection xqc = xqd.getConnection("admin", "admin"); XQExpression xqe = xqc.createExpression(); XQSequence xqs = xqe.executeQuery(SELECT); xqs.next(); long before = xqs.getLong(); System.out.println("Initial value: " + before); System.out.println("Updating..."); xqs = xqe.executeQuery(UPDATE); xqs = xqe.executeQuery(SELECT); xqs.next(); long after = xqs.getLong(); System.out.println("Resulting value: " + after); xqc.close(); Assert.assertEquals("Update should have succeeded or failed", before + 1, after); } catch (Exception e) { e.printStackTrace(); } }
Hi Arjan, thanks for your report. I managed to reproduce the issue. I assume that this behavior is due to XQJ, which is why I’m forwarding your mail to Charles. Hope this helps, Christian @Charles: if you have more questions, or if you believe that the bug is on our side.. Your feedback is welcome! ___________________________ On Wed, Aug 22, 2012 at 5:44 PM, Arjan van Bentem <arjan.vanbentem@bidnetwork.org> wrote:
Hi all,
Maybe this is related to http://xqj.net/basex/ instead of BaseX itself, but as I don't know allow me to ask here first.
Whenever I have somehow locked a BaseX database, like by using the standalone command line utility or the GUI, then I get something like the following in the BaseX log files:
QUERY(1) for $c in collection('factbook')//country[name='Albania']return( replace value of node $c/@population with xs:integer($c/@population + 1)) OK 39.92 ms QUERY(1) OK 0.62 ms FULL(1) Error: [BXDB0007] Database 'factbook' is opened by another process. CLOSE(1) OK 39.68 ms
Good.
However, I don't see that error in my Java code. The Java code just continues like all was fine.
Can I somehow make the Java code fail when this happens?
See example below, and the same thing in the attachment.
Thanks, Arjan.
private static final String DRIVER = "net.xqj.basex.BaseXXQDataSource";
private static final String SELECT = "xs:long(collection('factbook')//country[name='Albania']/@population[1]/data(.))";
private static final String UPDATE = "for $c in collection('factbook')//country[name='Albania']" + "return(" + " replace value of node $c/@population with xs:integer($c/@population + 1)" + ")";
@Test public void testUpdate() { try {
XQDataSource xqd = (XQDataSource) Class.forName(DRIVER) .newInstance(); XQConnection xqc = xqd.getConnection("admin", "admin"); XQExpression xqe = xqc.createExpression();
XQSequence xqs = xqe.executeQuery(SELECT); xqs.next(); long before = xqs.getLong(); System.out.println("Initial value: " + before);
System.out.println("Updating..."); xqs = xqe.executeQuery(UPDATE);
xqs = xqe.executeQuery(SELECT); xqs.next(); long after = xqs.getLong(); System.out.println("Resulting value: " + after);
xqc.close();
Assert.assertEquals("Update should have succeeded or failed", before + 1, after);
} catch (Exception e) { e.printStackTrace(); }
}
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Does the BaseX GUI open a Database via embedded mode, locking the Database it in the process? Please could you give me a couple more steps to go on Arjan? If there is a problem with the XQJ Driver I would like to fix it. Regards, Charles On 23 August 2012 03:53, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Arjan,
thanks for your report. I managed to reproduce the issue. I assume that this behavior is due to XQJ, which is why I’m forwarding your mail to Charles.
Hope this helps, Christian
@Charles: if you have more questions, or if you believe that the bug is on our side.. Your feedback is welcome! ___________________________
On Wed, Aug 22, 2012 at 5:44 PM, Arjan van Bentem <arjan.vanbentem@bidnetwork.org> wrote:
Hi all,
Maybe this is related to http://xqj.net/basex/ instead of BaseX itself, but as I don't know allow me to ask here first.
Whenever I have somehow locked a BaseX database, like by using the standalone command line utility or the GUI, then I get something like the following in the BaseX log files:
QUERY(1) for $c in collection('factbook')//country[name='Albania']return( replace value of node $c/@population with xs:integer($c/@population + 1)) OK 39.92 ms QUERY(1) OK 0.62 ms FULL(1) Error: [BXDB0007] Database 'factbook' is opened by another process. CLOSE(1) OK 39.68 ms
Good.
However, I don't see that error in my Java code. The Java code just continues like all was fine.
Can I somehow make the Java code fail when this happens?
See example below, and the same thing in the attachment.
Thanks, Arjan.
private static final String DRIVER = "net.xqj.basex.BaseXXQDataSource";
private static final String SELECT = "xs:long(collection('factbook')//country[name='Albania']/@population[1]/data(.))";
private static final String UPDATE = "for $c in collection('factbook')//country[name='Albania']" + "return(" + " replace value of node $c/@population with xs:integer($c/@population + 1)" + ")";
@Test public void testUpdate() { try {
XQDataSource xqd = (XQDataSource) Class.forName(DRIVER) .newInstance(); XQConnection xqc = xqd.getConnection("admin", "admin"); XQExpression xqe = xqc.createExpression();
XQSequence xqs = xqe.executeQuery(SELECT); xqs.next(); long before = xqs.getLong(); System.out.println("Initial value: " + before);
System.out.println("Updating..."); xqs = xqe.executeQuery(UPDATE);
xqs = xqe.executeQuery(SELECT); xqs.next(); long after = xqs.getLong(); System.out.println("Resulting value: " + after);
xqc.close();
Assert.assertEquals("Update should have succeeded or failed", before + 1, after);
} catch (Exception e) { e.printStackTrace(); }
}
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi all,
> Does the BaseX GUI open a Database via embedded mode, locking the
> Database it in the process?
It surely locks it, but I don't know how.
Note that I know I should not use the GUI to open the same database when
the database server is running too, but I don't know if it's the only error
that is not propagated? (I do get other errors, such as "XQJFOS021 -
FORWARD_ONLY_SEQUENCE: Cursor is not positioned on an XQItem" in my Java
code. Good. Also, if I try a non-existing database, I get "[FODC0002]:
Resource "[...]/basex/bin/xxxx-factbook" not found." in my Java code. Good
too.)
I know of two ways to mess up: the GUI, and the standalone command line
utility. It took me some time to realize that "bin/basex" is not some
TCP/IP client that connects to a running database server (as started with
"bin/basexserver"), but rather opens the database files itself. The GUI
does the same. So, I know I should use "bin/basexclient" instead, to
connect to the server, to ensure the server can still correctly handle
requests from my Java code.
In the unit test I attached earlier, I described some steps I forgot in the
message itself:
When the database is somehow in use, the Java code fails
silently. Like:
- Start the server, using:
$ basexserver -S
Server was started.
- Import Factbook, using:
$ basex
BaseX 7.3 [Standalone]
Try help to get more information.
> create db factbook ../mondial-3.0.xml
Database 'factbook' created in 592.53 ms.
> show databases
1 opened database(s):
- factbook (1x)
- Leave the standalone tool open, hence make the database
unavailable for updates by the server.
- Run this very unit test; though the log in data/.logs does show
the BXDB0007 error, the Java code just silently ignores that.
(As an aside: in the GUI, menu Database, Server Administration warns:
"Warning: The client/server architecture and the GUI are not synchronized.
The same database should not be opened from clients and the GUI.")
Regards,
Arjan.
On Thu, Aug 23, 2012 at 10:30 AM, Charles Foster <charles@cfoster.net>wrote:
> Does the BaseX GUI open a Database via embedded mode, locking the
> Database it in the process?
>
> Please could you give me a couple more steps to go on Arjan? If there
> is a problem with the XQJ Driver I would like to fix it.
>
> Regards,
>
> Charles
>
> On 23 August 2012 03:53, Christian Grün <christian.gruen@gmail.com> wrote:
> > Hi Arjan,
> >
> > thanks for your report. I managed to reproduce the issue. I assume
> > that this behavior is due to XQJ, which is why I’m forwarding your
> > mail to Charles.
> >
> > Hope this helps,
> > Christian
> >
> > @Charles: if you have more questions, or if you believe that the bug
> > is on our side.. Your feedback is welcome!
> > ___________________________
> >
> > On Wed, Aug 22, 2012 at 5:44 PM, Arjan van Bentem
> > <arjan.vanbentem@bidnetwork.org> wrote:
> >> Hi all,
> >>
> >> Maybe this is related to http://xqj.net/basex/ instead of BaseX
> itself, but
> >> as I don't know allow me to ask here first.
> >>
> >> Whenever I have somehow locked a BaseX database, like by using the
> >> standalone command line utility or the GUI, then I get something like
> the
> >> following in the BaseX log files:
> >>
> >> QUERY(1) for $c in
> collection('factbook')//country[name='Albania']return(
> >> replace value of node $c/@population with xs:integer($c/@population +
> 1)) OK
> >> 39.92 ms
> >> QUERY(1) OK 0.62 ms
> >> FULL(1) Error: [BXDB0007] Database 'factbook' is opened by another
> process.
> >> CLOSE(1) OK 39.68 ms
> >>
> >> Good.
> >>
> >> However, I don't see that error in my Java code. The Java code just
> >> continues like all was fine.
> >>
> >> Can I somehow make the Java code fail when this happens?
> >>
> >> See example below, and the same thing in the attachment.
> >>
> >> Thanks,
> >> Arjan.
> >>
> >>
> >>
> >> private static final String DRIVER = "net.xqj.basex.BaseXXQDataSource";
> >>
> >> private static final String SELECT =
> >>
> "xs:long(collection('factbook')//country[name='Albania']/@population[1]/data(.))";
> >>
> >> private static final String UPDATE = "for $c in
> >> collection('factbook')//country[name='Albania']"
> >> + "return("
> >> + " replace value of node $c/@population with
> xs:integer($c/@population +
> >> 1)"
> >> + ")";
> >>
> >> @Test
> >> public void testUpdate() {
> >> try {
> >>
> >> XQDataSource xqd = (XQDataSource) Class.forName(DRIVER)
> >> .newInstance();
> >> XQConnection xqc = xqd.getConnection("admin", "admin");
> >> XQExpression xqe = xqc.createExpression();
> >>
> >> XQSequence xqs = xqe.executeQuery(SELECT);
> >> xqs.next();
> >> long before = xqs.getLong();
> >> System.out.println("Initial value: " + before);
> >>
> >> System.out.println("Updating...");
> >> xqs = xqe.executeQuery(UPDATE);
> >>
> >> xqs = xqe.executeQuery(SELECT);
> >> xqs.next();
> >> long after = xqs.getLong();
> >> System.out.println("Resulting value: " + after);
> >>
> >> xqc.close();
> >>
> >> Assert.assertEquals("Update should have succeeded or failed",
> >> before + 1, after);
> >>
> >> } catch (Exception e) {
> >> e.printStackTrace();
> >> }
> >>
> >> }
> >>
> >>
> >> _______________________________________________
> >> BaseX-Talk mailing list
> >> BaseX-Talk@mailman.uni-konstanz.de
> >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
> >>
> >
>
Hi Arjan,
Usually, the BaseX server sends exceptions after executing an XQuery
in a specific text format, which includes debug information like line
numbers and so on which the BaseX XQJ client uses to subsequently
throw an XQQueryException.
In this particular instance, the BaseX server does not send the
exception in this expected format and the BaseX XQJ driver simply
ignores the exception, which isn't good at all.
That should no longer happen as of BaseX XQJ 1.2.1.
Please check out:
http://xqj.net/basex/basex-xqj-1.2.1.zip
I have also updated the Maven repository.
Let me know how you get on.
Kind Regards,
Charles
On 23 August 2012 10:29, Arjan van Bentem
<arjan.vanbentem@bidnetwork.org> wrote:
> Hi all,
>
>> Does the BaseX GUI open a Database via embedded mode, locking the
>> Database it in the process?
>
> It surely locks it, but I don't know how.
>
> Note that I know I should not use the GUI to open the same database when the
> database server is running too, but I don't know if it's the only error that
> is not propagated? (I do get other errors, such as "XQJFOS021 -
> FORWARD_ONLY_SEQUENCE: Cursor is not positioned on an XQItem" in my Java
> code. Good. Also, if I try a non-existing database, I get "[FODC0002]:
> Resource "[...]/basex/bin/xxxx-factbook" not found." in my Java code. Good
> too.)
>
> I know of two ways to mess up: the GUI, and the standalone command line
> utility. It took me some time to realize that "bin/basex" is not some TCP/IP
> client that connects to a running database server (as started with
> "bin/basexserver"), but rather opens the database files itself. The GUI does
> the same. So, I know I should use "bin/basexclient" instead, to connect to
> the server, to ensure the server can still correctly handle requests from my
> Java code.
>
> In the unit test I attached earlier, I described some steps I forgot in the
> message itself:
>
> When the database is somehow in use, the Java code fails
> silently. Like:
>
> - Start the server, using:
> $ basexserver -S
> Server was started.
>
> - Import Factbook, using:
> $ basex
> BaseX 7.3 [Standalone]
> Try help to get more information.
>
> > create db factbook ../mondial-3.0.xml
> Database 'factbook' created in 592.53 ms.
>
> > show databases
> 1 opened database(s):
> - factbook (1x)
>
> - Leave the standalone tool open, hence make the database
> unavailable for updates by the server.
>
> - Run this very unit test; though the log in data/.logs does show
> the BXDB0007 error, the Java code just silently ignores that.
>
> (As an aside: in the GUI, menu Database, Server Administration warns:
> "Warning: The client/server architecture and the GUI are not synchronized.
> The same database should not be opened from clients and the GUI.")
>
> Regards,
> Arjan.
>
>
> On Thu, Aug 23, 2012 at 10:30 AM, Charles Foster <charles@cfoster.net>
> wrote:
>>
>> Does the BaseX GUI open a Database via embedded mode, locking the
>> Database it in the process?
>>
>> Please could you give me a couple more steps to go on Arjan? If there
>> is a problem with the XQJ Driver I would like to fix it.
>>
>> Regards,
>>
>> Charles
>>
>> On 23 August 2012 03:53, Christian Grün <christian.gruen@gmail.com> wrote:
>> > Hi Arjan,
>> >
>> > thanks for your report. I managed to reproduce the issue. I assume
>> > that this behavior is due to XQJ, which is why I’m forwarding your
>> > mail to Charles.
>> >
>> > Hope this helps,
>> > Christian
>> >
>> > @Charles: if you have more questions, or if you believe that the bug
>> > is on our side.. Your feedback is welcome!
>> > ___________________________
>> >
>> > On Wed, Aug 22, 2012 at 5:44 PM, Arjan van Bentem
>> > <arjan.vanbentem@bidnetwork.org> wrote:
>> >> Hi all,
>> >>
>> >> Maybe this is related to http://xqj.net/basex/ instead of BaseX itself,
>> >> but
>> >> as I don't know allow me to ask here first.
>> >>
>> >> Whenever I have somehow locked a BaseX database, like by using the
>> >> standalone command line utility or the GUI, then I get something like
>> >> the
>> >> following in the BaseX log files:
>> >>
>> >> QUERY(1) for $c in
>> >> collection('factbook')//country[name='Albania']return(
>> >> replace value of node $c/@population with xs:integer($c/@population +
>> >> 1)) OK
>> >> 39.92 ms
>> >> QUERY(1) OK 0.62 ms
>> >> FULL(1) Error: [BXDB0007] Database 'factbook' is opened by another
>> >> process.
>> >> CLOSE(1) OK 39.68 ms
>> >>
>> >> Good.
>> >>
>> >> However, I don't see that error in my Java code. The Java code just
>> >> continues like all was fine.
>> >>
>> >> Can I somehow make the Java code fail when this happens?
>> >>
>> >> See example below, and the same thing in the attachment.
>> >>
>> >> Thanks,
>> >> Arjan.
>> >>
>> >>
>> >>
>> >> private static final String DRIVER = "net.xqj.basex.BaseXXQDataSource";
>> >>
>> >> private static final String SELECT =
>> >>
>> >> "xs:long(collection('factbook')//country[name='Albania']/@population[1]/data(.))";
>> >>
>> >> private static final String UPDATE = "for $c in
>> >> collection('factbook')//country[name='Albania']"
>> >> + "return("
>> >> + " replace value of node $c/@population with
>> >> xs:integer($c/@population +
>> >> 1)"
>> >> + ")";
>> >>
>> >> @Test
>> >> public void testUpdate() {
>> >> try {
>> >>
>> >> XQDataSource xqd = (XQDataSource) Class.forName(DRIVER)
>> >> .newInstance();
>> >> XQConnection xqc = xqd.getConnection("admin", "admin");
>> >> XQExpression xqe = xqc.createExpression();
>> >>
>> >> XQSequence xqs = xqe.executeQuery(SELECT);
>> >> xqs.next();
>> >> long before = xqs.getLong();
>> >> System.out.println("Initial value: " + before);
>> >>
>> >> System.out.println("Updating...");
>> >> xqs = xqe.executeQuery(UPDATE);
>> >>
>> >> xqs = xqe.executeQuery(SELECT);
>> >> xqs.next();
>> >> long after = xqs.getLong();
>> >> System.out.println("Resulting value: " + after);
>> >>
>> >> xqc.close();
>> >>
>> >> Assert.assertEquals("Update should have succeeded or failed",
>> >> before + 1, after);
>> >>
>> >> } catch (Exception e) {
>> >> e.printStackTrace();
>> >> }
>> >>
>> >> }
>> >>
>> >>
>> >> _______________________________________________
>> >> BaseX-Talk mailing list
>> >> BaseX-Talk@mailman.uni-konstanz.de
>> >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>> >>
>> >
>
>
Hi Charles,
Confirmed: with 1.2.1 I now get a nice:
javax.xml.xquery.XQException:
BXDB0007 - Database 'factbook' is opened by another process.
Thanks for the quick fix! I now see what the fast car on http://xqj.net/ stands
for ;-)
Arjan.
On Thu, Aug 23, 2012 at 6:02 PM, Charles Foster <charles@cfoster.net> wrote:
> Hi Arjan,
>
> Usually, the BaseX server sends exceptions after executing an XQuery
> in a specific text format, which includes debug information like line
> numbers and so on which the BaseX XQJ client uses to subsequently
> throw an XQQueryException.
>
> In this particular instance, the BaseX server does not send the
> exception in this expected format and the BaseX XQJ driver simply
> ignores the exception, which isn't good at all.
>
> That should no longer happen as of BaseX XQJ 1.2.1.
>
> Please check out:
>
> http://xqj.net/basex/basex-xqj-1.2.1.zip
>
> I have also updated the Maven repository.
>
> Let me know how you get on.
>
> Kind Regards,
>
> Charles
>
>
>
> On 23 August 2012 10:29, Arjan van Bentem
> <arjan.vanbentem@bidnetwork.org> wrote:
> > Hi all,
> >
> >> Does the BaseX GUI open a Database via embedded mode, locking the
> >> Database it in the process?
> >
> > It surely locks it, but I don't know how.
> >
> > Note that I know I should not use the GUI to open the same database when
> the
> > database server is running too, but I don't know if it's the only error
> that
> > is not propagated? (I do get other errors, such as "XQJFOS021 -
> > FORWARD_ONLY_SEQUENCE: Cursor is not positioned on an XQItem" in my Java
> > code. Good. Also, if I try a non-existing database, I get "[FODC0002]:
> > Resource "[...]/basex/bin/xxxx-factbook" not found." in my Java code.
> Good
> > too.)
> >
> > I know of two ways to mess up: the GUI, and the standalone command line
> > utility. It took me some time to realize that "bin/basex" is not some
> TCP/IP
> > client that connects to a running database server (as started with
> > "bin/basexserver"), but rather opens the database files itself. The GUI
> does
> > the same. So, I know I should use "bin/basexclient" instead, to connect
> to
> > the server, to ensure the server can still correctly handle requests
> from my
> > Java code.
> >
> > In the unit test I attached earlier, I described some steps I forgot in
> the
> > message itself:
> >
> > When the database is somehow in use, the Java code fails
> > silently. Like:
> >
> > - Start the server, using:
> > $ basexserver -S
> > Server was started.
> >
> > - Import Factbook, using:
> > $ basex
> > BaseX 7.3 [Standalone]
> > Try help to get more information.
> >
> > > create db factbook ../mondial-3.0.xml
> > Database 'factbook' created in 592.53 ms.
> >
> > > show databases
> > 1 opened database(s):
> > - factbook (1x)
> >
> > - Leave the standalone tool open, hence make the database
> > unavailable for updates by the server.
> >
> > - Run this very unit test; though the log in data/.logs does show
> > the BXDB0007 error, the Java code just silently ignores that.
> >
> > (As an aside: in the GUI, menu Database, Server Administration warns:
> > "Warning: The client/server architecture and the GUI are not
> synchronized.
> > The same database should not be opened from clients and the GUI.")
> >
> > Regards,
> > Arjan.
> >
> >
> > On Thu, Aug 23, 2012 at 10:30 AM, Charles Foster <charles@cfoster.net>
> > wrote:
> >>
> >> Does the BaseX GUI open a Database via embedded mode, locking the
> >> Database it in the process?
> >>
> >> Please could you give me a couple more steps to go on Arjan? If there
> >> is a problem with the XQJ Driver I would like to fix it.
> >>
> >> Regards,
> >>
> >> Charles
> >>
> >> On 23 August 2012 03:53, Christian Grün <christian.gruen@gmail.com>
> wrote:
> >> > Hi Arjan,
> >> >
> >> > thanks for your report. I managed to reproduce the issue. I assume
> >> > that this behavior is due to XQJ, which is why I’m forwarding your
> >> > mail to Charles.
> >> >
> >> > Hope this helps,
> >> > Christian
> >> >
> >> > @Charles: if you have more questions, or if you believe that the bug
> >> > is on our side.. Your feedback is welcome!
> >> > ___________________________
> >> >
> >> > On Wed, Aug 22, 2012 at 5:44 PM, Arjan van Bentem
> >> > <arjan.vanbentem@bidnetwork.org> wrote:
> >> >> Hi all,
> >> >>
> >> >> Maybe this is related to http://xqj.net/basex/ instead of BaseX
> itself,
> >> >> but
> >> >> as I don't know allow me to ask here first.
> >> >>
> >> >> Whenever I have somehow locked a BaseX database, like by using the
> >> >> standalone command line utility or the GUI, then I get something like
> >> >> the
> >> >> following in the BaseX log files:
> >> >>
> >> >> QUERY(1) for $c in
> >> >> collection('factbook')//country[name='Albania']return(
> >> >> replace value of node $c/@population with xs:integer($c/@population +
> >> >> 1)) OK
> >> >> 39.92 ms
> >> >> QUERY(1) OK 0.62 ms
> >> >> FULL(1) Error: [BXDB0007] Database 'factbook' is opened by another
> >> >> process.
> >> >> CLOSE(1) OK 39.68 ms
> >> >>
> >> >> Good.
> >> >>
> >> >> However, I don't see that error in my Java code. The Java code just
> >> >> continues like all was fine.
> >> >>
> >> >> Can I somehow make the Java code fail when this happens?
> >> >>
> >> >> See example below, and the same thing in the attachment.
> >> >>
> >> >> Thanks,
> >> >> Arjan.
> >> >>
> >> >>
> >> >>
> >> >> private static final String DRIVER =
> "net.xqj.basex.BaseXXQDataSource";
> >> >>
> >> >> private static final String SELECT =
> >> >>
> >> >>
> "xs:long(collection('factbook')//country[name='Albania']/@population[1]/data(.))";
> >> >>
> >> >> private static final String UPDATE = "for $c in
> >> >> collection('factbook')//country[name='Albania']"
> >> >> + "return("
> >> >> + " replace value of node $c/@population with
> >> >> xs:integer($c/@population +
> >> >> 1)"
> >> >> + ")";
> >> >>
> >> >> @Test
> >> >> public void testUpdate() {
> >> >> try {
> >> >>
> >> >> XQDataSource xqd = (XQDataSource) Class.forName(DRIVER)
> >> >> .newInstance();
> >> >> XQConnection xqc = xqd.getConnection("admin", "admin");
> >> >> XQExpression xqe = xqc.createExpression();
> >> >>
> >> >> XQSequence xqs = xqe.executeQuery(SELECT);
> >> >> xqs.next();
> >> >> long before = xqs.getLong();
> >> >> System.out.println("Initial value: " + before);
> >> >>
> >> >> System.out.println("Updating...");
> >> >> xqs = xqe.executeQuery(UPDATE);
> >> >>
> >> >> xqs = xqe.executeQuery(SELECT);
> >> >> xqs.next();
> >> >> long after = xqs.getLong();
> >> >> System.out.println("Resulting value: " + after);
> >> >>
> >> >> xqc.close();
> >> >>
> >> >> Assert.assertEquals("Update should have succeeded or failed",
> >> >> before + 1, after);
> >> >>
> >> >> } catch (Exception e) {
> >> >> e.printStackTrace();
> >> >> }
> >> >>
> >> >> }
> >> >>
> >> >>
> >> >> _______________________________________________
> >> >> BaseX-Talk mailing list
> >> >> BaseX-Talk@mailman.uni-konstanz.de
> >> >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
> >> >>
> >> >
> >
> >
>
participants (3)
-
Arjan van Bentem -
Charles Foster -
Christian Grün