Difference between revisions of "Java Examples"

From BaseX Documentation
Jump to navigation Jump to search
Line 51: Line 51:
 
==XML:DB API Examples==
 
==XML:DB API Examples==
  
Note that the XML:DB API does not communicate with the client/server architecture of BaseX.
+
The XML:DB API does not communicate with the client/server architecture of BaseX.
 +
This means that you should guarantee by yourself that only a single writing
 +
process accesses the databases at the same time.
  
 
;[[XMLDBCreate]]
 
;[[XMLDBCreate]]
Line 64: Line 66:
 
==XQJ API Example==
 
==XQJ API Example==
  
Note that the XQJ API does not communicate with the client/server architecture of BaseX.
+
The XQJ API does not communicate with the client/server architecture of BaseX.
 +
This means that you should guarantee by yourself that only a single writing
 +
process accesses the databases at the same time.
  
 
;[[XQJQuery]]
 
;[[XQJQuery]]

Revision as of 05:17, 17 April 2011

The following Java code snippets demonstrate how easy it is to run database commands, create collections, perform queries, etc. via the BaseX API.

The use of the XML:DB and XQJ APIs is generally discouraged; instead, we recommend everyone to use our own APIs, as they offer better performance and are better supported by our core team.

Local Examples

RunCommands
creates and drops database and index instances, prints a list of all existing databases.
WikiExample
creates a database from an url (wiki instance), runs a query against it and drops the database.
RunQueries
shows three variants of running queries.
CreateCollection
creates and manages a collection.
QueryCollection
creates, runs queries against it and drops a collection.

Server Examples

ServerCommands
launches server-side commands using a client session.
ServerAndLocal
processes server results locally.
ServerConcurrency
runs concurrent queries.
UserExample
manages database users.

JAX-RX API (REST) Examples

JaxRxGET
presents the HTTP GET method.
JaxRxPOSTAdd
presents the add function of the HTTP POST method.
JaxRxPOSTQuery
presents the query function of the HTTP POST method.
JaxRxPUT
presents the HTTP PUT method.
JaxRxDELETE
presents the HTTP DELETE method.

XML:DB API Examples

The XML:DB API does not communicate with the client/server architecture of BaseX. This means that you should guarantee by yourself that only a single writing process accesses the databases at the same time.

XMLDBCreate
creates a collection using XML:DB.
XMLDBQuery
runs a query using XML:DB.
XMLDBInsert
inserts a document into a database using XML:DB.

XQJ API Example

The XQJ API does not communicate with the client/server architecture of BaseX. This means that you should guarantee by yourself that only a single writing process accesses the databases at the same time.

XQJQuery
runs a query using XQJ.