From: Wolfgang M. <me...@if...> - 2002-07-08 09:31:47
|
Hi, I have been on holiday last week, so please excuse my late response ... The following code works with my installation. It retrieves a document fr= om=20 eXist running in embedded mode: package samples; import org.xmldb.api.*; import org.xmldb.api.base.*; import org.xmldb.api.modules.*; public class Test { public static void main( String args[] ) throws Exception { String driver =3D "org.exist.xmldb.DatabaseImpl"; String uri =3D "xmldb:exist:///db/shakespeare/plays"; Class cl =3D Class.forName( driver ); Database database =3D (Database) cl.newInstance(); database.setProperty( "create-database", "true" ); DatabaseManager.registerDatabase( database ); Collection root =3D DatabaseManager.getCollection( uri ); XMLResource res =3D (XMLResource) root.getResource( args[0] ); System.out.println( (String) res.getContent() ); } } Running bin/run.sh samples.Test hamlet.xml will retrieve file hamlet.xml = from=20 collection /db/shakespeare/plays. You may also use client.sh in embedded = mode=20 by changing the uri-parameter in client.properties to uri=3Dxmldb:exist:/// On Wednesday 03 July 2002 8:01 pm, Vladimir Bossicard wrote: > Hi all, > > I'm new to eXiste and want to embed the server into my application. I > tried the example (verbatim) proposed by Wolfgang but I have received a= n > "Unexpected Response from Server: Method Not Allowed". Does anyone ha= ve > successfully implemented an embedded server? If so, I would be really = glad > to see some code > > :-) > > Thanks > > -Vladimir |