dbTalk Databases Forums  

First-chance exception when debugging dBXML in VS6

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


Discuss First-chance exception when debugging dBXML in VS6 in the comp.databases.berkeley-db forum.



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

Default First-chance exception when debugging dBXML in VS6 - 01-29-2006 , 12:02 AM






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.


Reply With Quote
  #2  
Old   
John Snelson
 
Posts: n/a

Default Re: First-chance exception when debugging dBXML in VS6 - 01-30-2006 , 09:05 AM






DB XML is not meant to throw exceptions with no what() message - I
haven't seen behaviour like this before. I suggest you do two things:

1) Catch XmlException instead of std::exception, and see if that makes
a difference to the result of the what() function. It shouldn't - but
you never know.
2) Turn on logging, and see if any errors show up in the log:

http://www.sleepycat.com/xmldocs/gsg...xceptions.html

I hope this helps,

John


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.