Changes

Jump to navigation Jump to search
335 bytes removed ,  18:00, 2 March 2012
no edit summary
This page presents the code structure classes and functions of the BaseX clients,and the client/server underlying protocol needed to write [[Clients]], which is utilized for communicating within other programming languagesthe database server.
==DescriptionWorkflow==
* First of all, the a BaseX database server must be running in order to use , which will process the clientsclient requests.
* Each client provides a session class or script with methods to connect to and communicate with the database server. A socket connection will be established by the constructor, which expects a host, port, user name and password as arguments.
* For the execution of commands you need to call the <code>The {{Mono|execute()</code> }} method with the is called to launch a database command as argument. The method It returns the result or throws an exception with the received error message.
* The <code>{{Mono|query()</code> }} method creates a query instance. Variables can be bound to that object, and the result can either be requested by <code>via {{Mono|execute()</code>}}, or in an iterative manner with the <code>{{Mono|more()</code> }} and <code>{{Mono|next()</code> }} functions. If an error occurs, an exception will be thrown.
* The <code>{{Mono|create()</code>}}, <code>{{Mono|add()</code>}}, <code>{{Mono|replace()</code> }} and <code>{{Mono|store()</code> }} method can be used to pass on input streams to the corresponding database commands.
* To speed up execution, an output stream can be specified by some clients; this way, all results will be directed to that output stream.
==Transfer Protocol==
The All [[Clients]] use the following client/server protocol below has been introduced to communicate with Version 6the server.3.1 The description of BaseXthe protocol is helpful if you want to implement a new client.
Please note that the protocol for iterative query execution has changed a little, though: From Version 6.3.1 to 6.7.1 of BaseX, iterative queries could lead to deadlocks if query iterators were not properly closed. Since {{Version|7.0}}, the ITER command returns all results of a query in one go, and the iterative execution of clients is left to the client code. ===General Syntax===
* <code>\x</code>: single byte.
===Command Protocol===
The following byte sequences are sent and received from the client (please note that a specific client may, and need, not support all of the presented commands):
{| class="wikitable"
===Query Command Protocol===
Queries are referenced via an {{Mono|id}}, which is supplied has been returned by the server {{Mono|QUERY}} command (see QUERY command above):
{| class="wikitable"
| Binds a value to a variable.
|-
| ITERRESULTS
| <code>\4 {id}</code>
| <code>\t {item 1} ... \t {item n} \0</code>
| Returns all results of the query, prefixed by their [[Server Protocol/Data Types|Data Type]] encoded in {{Mono|\t}}.
|-
| EXECUTE
| <code>\31 {id}</code>
| <code>{meta 1} {item 1} ... {meta n} {item n} \0</code>
| {{Version|7.1.2}}: Returns all results of the query, prefixed by their [[Server Protocol/#XDM Meta Data|XDM meta data]].
|-
| ↯ error
|}
===XDM Meta Data=== ==Examples===
* [https://github.com/BaseXdb/basex-api/blob/master/src/main/java/BaseXClient.java Java client]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu