Difference between revisions of "Java Examples"

From BaseX Documentation
Jump to navigation Jump to search
Line 4: Line 4:
 
Our current XQJ API is based on Charles Foster’s [http://xqj.net/basex/ XQJ implementation], which fully utilized the client/server architecture of BaseX.
 
Our current XQJ API is based on Charles Foster’s [http://xqj.net/basex/ XQJ implementation], which fully utilized the client/server architecture of BaseX.
 
Note that the older {{Code|XML:DB}} API can only be used in embedded mode.
 
Note that the older {{Code|XML:DB}} API can only be used in embedded mode.
 +
 +
<div style="float:left; width:48%;">
  
 
==Local Examples==
 
==Local Examples==
 +
 
* [https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/basex/examples/query/RunCommands.java RunCommands.java]<br/>creates and drops database and index instances, prints a list of all existing databases.
 
* [https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/basex/examples/query/RunCommands.java RunCommands.java]<br/>creates and drops database and index instances, prints a list of all existing databases.
  
Line 25: Line 28:
  
 
* [https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/basex/examples/UserExample.java UserExample.java]<br/>manages database users.
 
* [https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/basex/examples/UserExample.java UserExample.java]<br/>manages database users.
 +
 +
</div><div style="float:left; width:4%;">&nbsp;
 +
</div><div style="float:left; width:48%;">
  
 
==[[REST API]]==
 
==[[REST API]]==
Line 43: Line 49:
  
 
* [https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/basex/examples/xmldb/XMLDBInsert.java XMLDBInsert.java]<br/>inserts a document into a database using XML:DB.
 
* [https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/basex/examples/xmldb/XMLDBInsert.java XMLDBInsert.java]<br/>inserts a document into a database using XML:DB.
 +
 +
</div>
  
 
[[Category:Developer]]
 
[[Category:Developer]]
 +
__NOTOC__

Revision as of 10:43, 6 June 2013

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.

Our current XQJ API is based on Charles Foster’s XQJ implementation, which fully utilized the client/server architecture of BaseX. Note that the older XML:DB API can only be used in embedded mode.

Local Examples

  • RunCommands.java
    creates and drops database and index instances, prints a list of all existing databases.
  • WikiExample.java
    creates a database from an url (wiki instance), runs a query against it and drops the database.

Server Examples

 

REST API

XML:DB API (deprecated)