This page is part of the Developer Section. The following Java code snippets demonstrate how easy it is to run database commands, create collections, perform queries, etc. via the BaseX API. Most examples are taken from our basex-examples repository, in which you will find some more use cases.
Note that we recommend everyone to use our own APIs, as they offer better performance and are better supported by our core team. The use of the
XQJ APIs is discouraged: as these APIs do not utilize the client/server architecture of BaseX, their use may lead to conflicting database access operations.
- creates and drops database and index instances, prints a list of all existing databases.
- creates a database from an url (wiki instance), runs a query against it and drops the database.
- shows three variants of running queries.
- creates and manages a collection.
- creates, runs queries against it and drops a collection.
- launches server-side commands using a client session.
- processes server results locally.
- runs concurrent queries.
- manages database users.
REST API Examples
- presents the HTTP GET method.
- presents the HTTP POST method.
- presents the HTTP PUT method.
- presents the HTTP DELETE method.
XML:DB API Examples
- creates a collection using XML:DB.
- runs a query using XML:DB.
- inserts a document into a database using XML:DB.
XQJ API Example
Since Version 7.2.1, BaseX uses Charles Foster’s generic XQJ API.