dbTalk Databases Forums  

Newbie BerkeleyDB XML question

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Newbie BerkeleyDB XML question in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rupert Woodman
 
Posts: n/a

Default Newbie BerkeleyDB XML question - 06-30-2006 , 02:38 PM






I'm having some problems getting started with BerkeleyDB XML and I'd really
appreciate some help or guidance.

I've written a java application which reads some XML from a file and writes
it to a container.
Unfortunately, I have a couple of peoblems.
The first one, is than unless I enable auto-open, it tells me the container
is closed. I've looked at the source and it's failing somewhere in the
native methds which makes it difficult to resolve. This is less of a
problem to me at the minute, tho I note that someone from Sleepycat said
it's a slow way of doing things.

The other problem is more of a show-stopper:

Opening container TestMetadata.dbxml
Container - TestMetadata.dbxml - Node storage container opened.
Opening container TestMetadata.dbxml
Indexer - XML Indexer: Fatal Parse error in document at line, 1, char 23.
Parser message: An exception occurred! Type:UTFDataFormatException,
Message:invalid byte 1 (?) of a 1-byte sequence.

The XML data file is valid (if slightly dull):

<?xml version="1.0" ?>

<metadata>
<test id="1" name="test1">

</test>

<test id="2" name="test2">

</test>

</metadata>

I don't see why this should fail with such an error.

The method I'm using to write the data is as follows:

public boolean write(String strDocKey, String strXmlDoc) throws
XmlException
{
boolean boolRetVal = true;

try {
semWriteAccess.acquire();

openContainer();

// Do write
XmlTransaction xtTrans = xmManager.createTransaction();

XmlUpdateContext xucUpdate =
xmManager.createUpdateContext();

xcContainer.putDocument(xtTrans, strDocKey, strXmlDoc,
xucUpdate);

xtTrans.commit();

} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
boolRetVal = false;
} finally {
semWriteAccess.release();
}

return boolRetVal;
}


I'm setting up as follows:

Environment envCurrent =
getEnvironment(BERKELEY_TEST_REPOSITORY_HOME);

XmlManagerConfig xmc = new XmlManagerConfig();

xmc.setAllowAutoOpen(true);

xmManager = new XmlManager(envCurrent, xmc);

xmManager.setLogLevel(XmlManager.LEVEL_ALL, true);
xmManager.setLogCategory(XmlManager.CATEGORY_ALL, true);



public Environment getEnvironment(String strBase) throws
FileNotFoundException, DatabaseException
{
File f = new File(strBase);

EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setMaxLocks(10000);
envConf.setMaxLockers(10000);
envConf.setMaxLockObjects(10000);

envConf.setCacheSize(50 * 1024 * 1024);
envConf.setAllowCreate(true);
envConf.setInitializeCache(true);
envConf.setTransactional(true);
envConf.setInitializeLocking(true);
envConf.setInitializeLogging(true);
envConf.setErrorStream(System.err);

Environment myEnv = new Environment(f, envConf);

return myEnv;
}

Any ideas, please let me know - I'm really keen to get this going.

Thanks



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.