Database Reference
In-Depth Information
Table 13-9. Additional dependency for using the XML:DB Local API
Library
Description
Scope
$EXIST_HOME/lib/core/xmlrpc-
client-3.1.3.jar
Apache XML-RPC client library.
Dependency of eXist's XML:DB API, even when using XML:DB local mode!
Runtime
The XML:DB Local API is almost identical to the XML:DB Remote API (see
“XML:DB Remote API” on page 349 ), so we will only discuss where it differs from
the Remote API. Therefore, reading “XML:DB Remote API” on page 349 first should
be considered a requirement for understanding the Local API. Differences you need
to be aware of are:
Collections
Conceptually, collections in the Local API are exactly the same as in the Remote
API; the only difference is the URI format that you use to access them. As the
database is running in the same JVM there is no remote server, so you need not
provide the server name, port, or endpoint in the URI. Instead, you just need the
collection path. See Example 13-18 .
Example 13-18. Opening an XML:DB local collection to eXist
Collection collection =
DatabaseManager . getCollection ( "xmldb:exist://db" , "admin" , "" );
Database shutdown
When you first access an embedded database collection, an eXist embedded data‐
base is automatically started for you. To maintain database consistency, you are
responsible for cleanly shutting down the eXist database either before your appli‐
cation terminates or when you have finished with the database inside your appli‐
cation. See Example 13-19 .
Example 13-19. Shutting down eXist with the XML:DB Local API
final DatabaseInstanceManager manager =
( DatabaseInstanceManager ) coll . getService ( "DatabaseInstanceManager" , "1.0" );
try {
coll . close ();
} finally {
manager . shutdown ();
}
 
Search WWH ::




Custom Search