Opening container question -
06-21-2006
, 10:00 AM
Hi,
I'm just having a look at BerkeleyDB XML for the first time, using the Java
API.
I created a new container using the Berkeley DB XML Shell (Tests.dbxml)
using the command:
createContainer "Tests.dbxml"
I then wrote an application to open the container, but I get an exception
thrown:
Container - Tests.dbxml - container closed.
com.sleepycat.dbxml.XmlException: Error: No such file or directory, errcode
= DATABASE_ERROR
at com.sleepycat.dbxml.dbxml_javaJNI.XmlManager_openC ontainer__SWIG_2(Native
Method)
at com.sleepycat.dbxml.XmlManager.openContainer(XmlMa nager.java:473)
at com.sleepycat.dbxml.XmlManager.openContainer(XmlMa nager.java:187)
at com.sleepycat.dbxml.XmlManager.openContainer(XmlMa nager.java:131)
at com.microfocus.XMLRepository.dbExample.<init>(dbEx ample.java:40)
at com.microfocus.XMLRepository.dbExample.main(dbExam ple.java:52)
If I call the existsContainer method before I make the call to
openContainer, it returns a value of 5.
However, if I create a container ("Test.xml") using
XmlManager.createContainer method, the same openContainer method, it works
ok.
I'm sure I must be missing something obviosu here, but I've not found
anything in the docs I've read so far.
thanks very much
Code below:
try {
File f = new File("c:/Documents and Settings/rupertw/");
String strContainer = "Tests.dbxml";
EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setCacheSize(50 * 1024 * 1024);
envConf.setInitializeCache(true);
envConf.setInitializeLogging(true);
envConf.setErrorStream(System.err);
Environment myEnv = new Environment(f, envConf);
xmManager = new XmlManager(myEnv, null);
xmManager.setLogLevel(XmlManager.LEVEL_ALL, true);
xmManager.setLogCategory(XmlManager.CATEGORY_ALL, true);
System.err.println("existsContainer returns: " +
xmManager.existsContainer(strContainer));
XmlContainer x = xmManager.openContainer(strContainer);
System.err.println("Opened ok");
} catch (XmlException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} |