Hi,
I am using berkley dbxml ver-2.2.13.
I downloaded the binary package from sleepycats site so it came bundled
with everything required to work.
My problem is that i get an exception when creating a container.The
source code is as below.
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++
//c++ class source file
#include "stdafx.h"
#include "Cberkley.h"
Cberkley::Cberkley()
{
(*this).env=new DbEnv(0);
(*this).env->set_cachesize(0, 64 * 1024 * 1024, 1);
(*this).env_flags=DB_CREATE | // If the environment does not
// exist, create it.
DB_INIT_LOCK | // Initialize the locking
subsystem
DB_INIT_LOG | // Initialize the logging
subsystem
DB_INIT_MPOOL | // Initialize the cache
DB_INIT_TXN; // Initialize transactions
(*this).db_home=(*this).getDbHome();
(*this).Dbmgr=NULL;
(*this).db_dfilename="logicdb.bdbxml";
}
string Cberkley::getDbHome()
{
string temp;
TCHAR *lpfilename=new TCHAR[MAX_PATH];
GetModuleFileName(NULL,lpfilename,MAX_PATH);
temp=lpfilename;
temp=temp.substr(0,temp.rfind("\\"));
return temp;
}
bool Cberkley:

bInit()
{
try{
if(!(*this).env->open((*this).db_home.c_str(),(*this).env_flags,0) )
//open The BerkleyDB Environment
{
(*this).Dbmgr=new XmlManager((*this).env,DBXML_ADOPT_DBENV);//supply
the xmlmanager the pre created environment
return true;
}
else
{
return false;
}
}
catch(DbException &e)
{
return false;
}
catch(std::exception &e) {
return false;
}
}
void Cberkley::CreateContainer()
{
try{
(*this).Dbmgr->createContainer((*this).db_dfilename);
(*this).Dbcontainer=(*this).Dbmgr->openContainer((*this).db_dfilename,DB_EXCL);
}
catch(DbException &e){
return;
}
catch(std::exception &xe)
{
return;
}
}
void Cberkley::AddDocument(string matter)
{
XmlUpdateContext Dbupdatecntxt;
//XmlDocument myXMLDoc = db.createDocument();
Dbupdatecntxt = (*this).Dbmgr->createUpdateContext();
try{
(*this).Dbcontainer.putDocument("ABCD1234","<A><B> assdddfffffff</B></A>",Dbupdatecntxt,0);
}
catch(XmlException &e)
{
return ;
}
catch(DbException &db)
{
return ;
}
}
bool Cberkley::AddToBDB(string matter)
{
if(!(*this).DbInit())return false;
(*this).CreateContainer();
//(*this).AddDocument(matter);
return true;
}
Cberkley::~Cberkley()
{
try{
if((*this).Dbcontainer!=NULL) delete (*this).Dbcontainer;
}
catch(DbException &e){
return;
}
catch(XmlException &xe){
return;
}
try{
if((*this).Dbmgr!=NULL) delete (*this).Dbmgr;
}
catch(DbException &e){
return;
}
catch(XmlException &xe){
return;
}
try{
(*this).env->close(0);
}
catch(DbException &e){
return;
}
catch(std::exception &e){
return;
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++
//c++ class header file
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++
#include <DbXml.hpp>
#include "stdafx.h"
using namespace DbXml;
class Cberkley
{
public:
Cberkley();
bool AddToBDB(string);
~Cberkley();
private:
string getDbHome();
bool DbInit();
void CreateContainer();
void AddDocument(string);
void GetDocument();
private:
DbEnv *env;
u_int32_t env_flags;
XmlManager *Dbmgr;
XmlContainer Dbcontainer;
string db_home;
string db_dfilename;
};
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++
the addtodb function is the driver function that calls
bool DbInit();
void CreateContainer();-->Exception In this
void AddDocument(string);
functions in turn,the exception is caused when creating the container
in the CreateContainer function and std exception caught has the what
member blank .
Plz adivise.